From patchwork Mon Sep 16 12:01:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986094 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=HaVvNJGB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6791-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k9T42V6z1y1C for ; Mon, 16 Sep 2024 22:04:29 +1000 (AEST) 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 737861C230C0 for ; Mon, 16 Sep 2024 12:04:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDE21159571; Mon, 16 Sep 2024 12:02:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HaVvNJGB" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 E628F158DA0; Mon, 16 Sep 2024 12:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488173; cv=none; b=hQPJY3rvRtmhCDpcjuV3LAQUeyBGLUiR8tpurTMQ1w1fBWN/nGkqNVfYuZlUGWDIp/eChRRkvlFnTvZH/K4GosM7VQCy+5eFvBrc3y4OBhtSL/Ztx7jeqlYMECpCtZiNEjG1StuMwzAJFcOuf04eo5CYKqHXLLVeb33fzwYCmxo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488173; c=relaxed/simple; bh=WxtYlBGVCCxL+Las691qhrqx8d/+iyr6qXtIQAGc/Ic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FgvJrpLe1A1uxgcuA//4nCEg4ONPFv4mq0g32cdkVrzu4W7JZol917Z3xM0wKpWVcj4N+B9y1wLT1LE7Ze2WaiTSAFNSj3Gh2QvFnBbHxSL/r6DKI+GIDk0miKZIhJpZmMuU+iEhaUR8Yc9b4XRaLThPLDSKtuvJLj1cWz5HpJk= 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=HaVvNJGB; arc=none smtp.client-ip=192.198.163.7 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=1726488172; x=1758024172; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WxtYlBGVCCxL+Las691qhrqx8d/+iyr6qXtIQAGc/Ic=; b=HaVvNJGBN50oi2JAlGSlegXmDBwcq6Zw0J2eackhXO/3dYgs2xaCIiQP 8Eq5lKfSEz0WYoyin6Lt7r6O4Hnn7huLF3+qbtahIvsBG6D0azSzVEDTb s2nF2+j5XVHK0GiPecVjzmLq5IWwf1oRDI6+wKM79bUunR+DQ3w1ESLYv vW9VcvulJwHMVbc2nqFteehZuu6D60YchxGtXOoup5lLV8XoqRClGqI5m R+Y5nPMDZJUrn5SAmmZysD1lAVpk/laWKz6BlnnxT2iuzPCHsaTWMlL1J Z0i/J5/M/o4nbxhX4Do7zUKIyrPd9XZt3oBQprU2Bn93C1nvjJZoiVKGL g==; X-CSE-ConnectionGUID: fyF7t7kzR+a6dTuU2kE8cA== X-CSE-MsgGUID: rNCrHRzORAWk1n6nuyhIiA== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="50725465" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="50725465" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:41 -0700 X-CSE-ConnectionGUID: oIHKOEOwRnO4a2ffpVE3BQ== X-CSE-MsgGUID: 1uBf27j1SnGh25yb0UNc1w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="72939876" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa003.fm.intel.com with ESMTP; 16 Sep 2024 05:02:40 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AB6F03CB; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 01/11] i2c: isch: Pass pointer to struct i2c_adapter down Date: Mon, 16 Sep 2024 15:01:28 +0300 Message-ID: <20240916120237.1385982-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are a lot of messaging calls that use global variable of struct i2c_adapter. Instead, to make code better and flexible for further improvements, pass the pointer to the actual adapter used for transfers. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 53 +++++++++++++++-------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index f59158489ad9..96ee73fe6e81 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -55,14 +55,15 @@ MODULE_PARM_DESC(backbone_speed, "Backbone speed in kHz, (default = 33000)"); * and this function will execute it. * return 0 for success and others for failure. */ -static int sch_transaction(void) +static int sch_transaction(struct i2c_adapter *adap) { int temp; int result = 0; int retries = 0; - dev_dbg(&sch_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, " - "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb(SMBHSTCNT), + dev_dbg(&adap->dev, + "Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", + inb(SMBHSTCNT), inb(SMBHSTCMD), inb(SMBHSTADD), inb(SMBHSTDAT0), inb(SMBHSTDAT1)); @@ -70,19 +71,14 @@ static int sch_transaction(void) temp = inb(SMBHSTSTS) & 0x0f; if (temp) { /* Can not be busy since we checked it in sch_access */ - if (temp & 0x01) { - dev_dbg(&sch_adapter.dev, "Completion (%02x). " - "Clear...\n", temp); - } - if (temp & 0x06) { - dev_dbg(&sch_adapter.dev, "SMBus error (%02x). " - "Resetting...\n", temp); - } + if (temp & 0x01) + dev_dbg(&adap->dev, "Completion (%02x). Clear...\n", temp); + if (temp & 0x06) + dev_dbg(&adap->dev, "SMBus error (%02x). Resetting...\n", temp); outb(temp, SMBHSTSTS); temp = inb(SMBHSTSTS) & 0x0f; if (temp) { - dev_err(&sch_adapter.dev, - "SMBus is not ready: (%02x)\n", temp); + dev_err(&adap->dev, "SMBus is not ready: (%02x)\n", temp); return -EAGAIN; } } @@ -97,31 +93,30 @@ static int sch_transaction(void) /* If the SMBus is still busy, we give up */ if (retries > MAX_RETRIES) { - dev_err(&sch_adapter.dev, "SMBus Timeout!\n"); + dev_err(&adap->dev, "SMBus Timeout!\n"); result = -ETIMEDOUT; } else if (temp & 0x04) { result = -EIO; - dev_dbg(&sch_adapter.dev, "Bus collision! SMBus may be " - "locked until next hard reset. (sorry!)\n"); + dev_dbg(&adap->dev, "Bus collision! SMBus may be locked until next hard reset. (sorry!)\n"); /* Clock stops and target is stuck in mid-transmission */ } else if (temp & 0x02) { result = -EIO; - dev_err(&sch_adapter.dev, "Error: no response!\n"); + dev_err(&adap->dev, "Error: no response!\n"); } else if (temp & 0x01) { - dev_dbg(&sch_adapter.dev, "Post complete!\n"); + dev_dbg(&adap->dev, "Post complete!\n"); outb(temp, SMBHSTSTS); temp = inb(SMBHSTSTS) & 0x07; if (temp & 0x06) { /* Completion clear failed */ - dev_dbg(&sch_adapter.dev, "Failed reset at end of " - "transaction (%02x), Bus error!\n", temp); + dev_dbg(&adap->dev, + "Failed reset at end of transaction (%02x), Bus error!\n", temp); } } else { result = -ENXIO; - dev_dbg(&sch_adapter.dev, "No such address.\n"); + dev_dbg(&adap->dev, "No such address.\n"); } - dev_dbg(&sch_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, " - "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb(SMBHSTCNT), + dev_dbg(&adap->dev, "Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", + inb(SMBHSTCNT), inb(SMBHSTCMD), inb(SMBHSTADD), inb(SMBHSTDAT0), inb(SMBHSTDAT1)); return result; @@ -143,7 +138,7 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, /* Make sure the SMBus host is not busy */ temp = inb(SMBHSTSTS) & 0x0f; if (temp & 0x08) { - dev_dbg(&sch_adapter.dev, "SMBus busy (%02x)\n", temp); + dev_dbg(&adap->dev, "SMBus busy (%02x)\n", temp); return -EAGAIN; } temp = inw(SMBHSTCLK); @@ -154,13 +149,11 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, * 100 kHz. If we actually run at 25 MHz the bus will be * run ~75 kHz instead which should do no harm. */ - dev_notice(&sch_adapter.dev, - "Clock divider uninitialized. Setting defaults\n"); + dev_notice(&adap->dev, "Clock divider uninitialized. Setting defaults\n"); outw(backbone_speed / (4 * 100), SMBHSTCLK); } - dev_dbg(&sch_adapter.dev, "access size: %d %s\n", size, - (read_write)?"READ":"WRITE"); + dev_dbg(&adap->dev, "access size: %d %s\n", size, (read_write)?"READ":"WRITE"); switch (size) { case I2C_SMBUS_QUICK: outb((addr << 1) | read_write, SMBHSTADD); @@ -205,10 +198,10 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, dev_warn(&adap->dev, "Unsupported transaction %d\n", size); return -EOPNOTSUPP; } - dev_dbg(&sch_adapter.dev, "write size %d to 0x%04x\n", size, SMBHSTCNT); + dev_dbg(&adap->dev, "write size %d to 0x%04x\n", size, SMBHSTCNT); outb((inb(SMBHSTCNT) & 0xb0) | (size & 0x7), SMBHSTCNT); - rc = sch_transaction(); + rc = sch_transaction(adap); if (rc) /* Error in transaction */ return rc; From patchwork Mon Sep 16 12:01:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986089 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Q1Xqre9Q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6786-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k7y4sWbz1y1C for ; Mon, 16 Sep 2024 22:03:10 +1000 (AEST) 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4D3D41C21204 for ; Mon, 16 Sep 2024 12:03:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E857156F27; Mon, 16 Sep 2024 12:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Q1Xqre9Q" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 404E4155C8A; Mon, 16 Sep 2024 12:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488167; cv=none; b=Bx5DiF9uTshC2Ls+ucZW3kIlzP97LiVLILgNcPovIrxLOtaiAVwZUZ2Eyz16AmXzp6dsDFpyWV13ps/cQEjlfpCmAiqrqLZf8ZszdCFzgD9PQR1eEK+ncqidPvsycdFq+CRK9LxBIGT+v1gLaRuHlryF1floHaSHUZ4Hi6B2Svc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488167; c=relaxed/simple; bh=Taa17+tLPBdmnRuoMJ/IqSoAFLOrHizGCjbHljk5goo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qnzfl0TS3gD1bKcZbQBy5EpY7Tv3nPaFyERyE0b5rBGyKzXjl2Nu6Asrct3dB5oCVMmIW6drRjhdF+qsFSw5fWePHU7HAjRHsV/x+6QNYDN/2luxsoBp+AHG9fb8TeIhzRP0Q4TDo/ii8riWJ/kDAV8TWkJw+sGHxO+6eFcNjiU= 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=Q1Xqre9Q; arc=none smtp.client-ip=192.198.163.19 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=1726488166; x=1758024166; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Taa17+tLPBdmnRuoMJ/IqSoAFLOrHizGCjbHljk5goo=; b=Q1Xqre9Qxng1RxmeKdk2YscqdRD3CLPX+M4/uY907173D6TUO+AA4FV3 rRDl3xh03GhFo4upxuOstdmULHXQLNu8ICB/JC4LoZG1Scw5ZENObkgvi SWeorTVGTFicnFc9Ix3sEkckD9vv6RAlEzmRGzcSJhb/gCHuwTK8Q1gFk X+TxpVXE+7ROgbGovV6asl/tn4x2qms2gK/JjQqaQzl8TpSUvCley2yIF bvxHLNsQ8le4rYoQo8v+q4yMJ6CDuPgxLc/gbTGqOdD3pEvTuEs9L31jv 9nxRr13f04fgrhyAEyhxquhA2KQgWJ+MoDclIwmcvN2XkvKJqXftQYTZF Q==; X-CSE-ConnectionGUID: 8nLRCup8QUmOt6BSznCA/g== X-CSE-MsgGUID: W2cjrPwtRSivFpK+4vi4wg== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="24842810" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="24842810" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:42 -0700 X-CSE-ConnectionGUID: MoCSaXX/QtyfMPUayobVEQ== X-CSE-MsgGUID: jZzh7f3FT16GMinzuOY77Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="68540770" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 16 Sep 2024 05:02:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B4D9C640; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 02/11] i2c: isch: Use string_choices API instead of ternary operator Date: Mon, 16 Sep 2024 15:01:29 +0300 Message-ID: <20240916120237.1385982-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use modern string_choices API instead of manually determining the output using ternary operator. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index 96ee73fe6e81..f44c5fa276dc 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -19,10 +19,11 @@ #include #include #include -#include #include #include #include +#include +#include /* SCH SMBus address offsets */ #define SMBHSTCNT (0 + sch_smba) @@ -153,7 +154,7 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, outw(backbone_speed / (4 * 100), SMBHSTCLK); } - dev_dbg(&adap->dev, "access size: %d %s\n", size, (read_write)?"READ":"WRITE"); + dev_dbg(&adap->dev, "access size: %d %s\n", size, str_read_write(read_write)); switch (size) { case I2C_SMBUS_QUICK: outb((addr << 1) | read_write, SMBHSTADD); From patchwork Mon Sep 16 12:01:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986086 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=D60d0ALZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6783-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k7b2VDHz1y1C for ; Mon, 16 Sep 2024 22:02:51 +1000 (AEST) 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id ADFB51C20AD3 for ; Mon, 16 Sep 2024 12:02:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29D79155391; Mon, 16 Sep 2024 12:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="D60d0ALZ" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 607D1155336; Mon, 16 Sep 2024 12:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488164; cv=none; b=hpshSZ594U/7sDWY2gd83ZpeNID88lWuab1GQuVYmLe6yx7EG74uaZM0yzN4e5XYAg55DMt6CsG3tMS08MKjghbEUrXthyluXULWUSA2xwJ7kPXjiFaCfEugCyO7O+V7eELIX/t2fBE+bvhR03wVd2rY5sEBmTigLKJE0opPigg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488164; c=relaxed/simple; bh=3+5K77XZCfuqChhbs/2CXk8I7TKi0QsRyShTaJryNVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NekbEfPwngEs3bGgS2n803Gy38W4RTr7EySRdvV0Se6bwzffWT+/AcqAYCi3HDgmHKN7/kuNSvTY5DsSjyDEhKp4BN1DnVGk68/7YdAD8x8Pjd7ADUQpNQhHGuOOahaXxbuxcCLsP4a0I5OvtSnExSpTD3lZiz5nrkX0xv6Q8ms= 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=D60d0ALZ; arc=none smtp.client-ip=192.198.163.19 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=1726488163; x=1758024163; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3+5K77XZCfuqChhbs/2CXk8I7TKi0QsRyShTaJryNVg=; b=D60d0ALZYiq9rbAQaGt5ThEEtpyMtUeB3B1+gRp6aKL4OxaChbfqK2UW agpoHYuuqcFYiS3gY4OztcSYm6W6k4KDQQTLzayV8CeHkrGXc6dOd2YcF AHvCWByl/yeKeiMMk39BWK/rGU17oHttatsiJR85Uz4FmLHE2I0oYXslF eiahzBPdbqWCI7SLqLYfdzp/h6xeupkY6amrd1f2In+njWO4IrRkLgElO KwmkJ3yGHxu/CKVx3GG7VdCpH5lxNpH+fILymjJL097GRtCQ05C531aFa cz1Yz/nJHH7YISfy7StnmIL1UxGlvF2P4hGqEiDfQRh3v4GWULkcaeNXC Q==; X-CSE-ConnectionGUID: e9CZKYjYR5mZvxE/xpbgKw== X-CSE-MsgGUID: V4360GjrS5+rDQZDni4ssg== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="24842806" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="24842806" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:42 -0700 X-CSE-ConnectionGUID: P4UM+2LLQo+ODqetOc3lVg== X-CSE-MsgGUID: MSCHM0yFR3SSTBOy0jzNIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="68540771" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 16 Sep 2024 05:02:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BFEB6641; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 03/11] i2c: isch: Switch to memory mapped IO accessors Date: Mon, 16 Sep 2024 15:01:30 +0300 Message-ID: <20240916120237.1385982-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert driver to use memory mapped IO accessors. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 133 ++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 55 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index f44c5fa276dc..0eaefb7b8bca 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -24,16 +24,17 @@ #include #include #include +#include /* SCH SMBus address offsets */ -#define SMBHSTCNT (0 + sch_smba) -#define SMBHSTSTS (1 + sch_smba) -#define SMBHSTCLK (2 + sch_smba) -#define SMBHSTADD (4 + sch_smba) /* TSA */ -#define SMBHSTCMD (5 + sch_smba) -#define SMBHSTDAT0 (6 + sch_smba) -#define SMBHSTDAT1 (7 + sch_smba) -#define SMBBLKDAT (0x20 + sch_smba) +#define SMBHSTCNT 0x00 +#define SMBHSTSTS 0x01 +#define SMBHSTCLK 0x02 +#define SMBHSTADD 0x04 /* TSA */ +#define SMBHSTCMD 0x05 +#define SMBHSTDAT0 0x06 +#define SMBHSTDAT1 0x07 +#define SMBBLKDAT 0x20 /* Other settings */ #define MAX_RETRIES 5000 @@ -45,12 +46,33 @@ #define SCH_WORD_DATA 0x03 #define SCH_BLOCK_DATA 0x05 -static unsigned short sch_smba; static struct i2c_adapter sch_adapter; +static void __iomem *sch_smba; + static int backbone_speed = 33000; /* backbone speed in kHz */ module_param(backbone_speed, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(backbone_speed, "Backbone speed in kHz, (default = 33000)"); +static inline u8 sch_io_rd8(void __iomem *smba, unsigned int offset) +{ + return ioread8(smba + offset); +} + +static inline void sch_io_wr8(void __iomem *smba, unsigned int offset, u8 value) +{ + iowrite8(value, smba + offset); +} + +static inline u16 sch_io_rd16(void __iomem *smba, unsigned int offset) +{ + return ioread16(smba + offset); +} + +static inline void sch_io_wr16(void __iomem *smba, unsigned int offset, u16 value) +{ + iowrite16(value, smba + offset); +} + /* * Start the i2c transaction -- the i2c_access will prepare the transaction * and this function will execute it. @@ -64,20 +86,20 @@ static int sch_transaction(struct i2c_adapter *adap) dev_dbg(&adap->dev, "Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", - inb(SMBHSTCNT), - inb(SMBHSTCMD), inb(SMBHSTADD), inb(SMBHSTDAT0), - inb(SMBHSTDAT1)); + sch_io_rd8(sch_smba, SMBHSTCNT), sch_io_rd8(sch_smba, SMBHSTCMD), + sch_io_rd8(sch_smba, SMBHSTADD), + sch_io_rd8(sch_smba, SMBHSTDAT0), sch_io_rd8(sch_smba, SMBHSTDAT1)); /* Make sure the SMBus host is ready to start transmitting */ - temp = inb(SMBHSTSTS) & 0x0f; + temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; if (temp) { /* Can not be busy since we checked it in sch_access */ if (temp & 0x01) dev_dbg(&adap->dev, "Completion (%02x). Clear...\n", temp); if (temp & 0x06) dev_dbg(&adap->dev, "SMBus error (%02x). Resetting...\n", temp); - outb(temp, SMBHSTSTS); - temp = inb(SMBHSTSTS) & 0x0f; + sch_io_wr8(sch_smba, SMBHSTSTS, temp); + temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; if (temp) { dev_err(&adap->dev, "SMBus is not ready: (%02x)\n", temp); return -EAGAIN; @@ -85,11 +107,13 @@ static int sch_transaction(struct i2c_adapter *adap) } /* start the transaction by setting bit 4 */ - outb(inb(SMBHSTCNT) | 0x10, SMBHSTCNT); + temp = sch_io_rd8(sch_smba, SMBHSTCNT); + temp |= 0x10; + sch_io_wr8(sch_smba, SMBHSTCNT, temp); do { usleep_range(100, 200); - temp = inb(SMBHSTSTS) & 0x0f; + temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); /* If the SMBus is still busy, we give up */ @@ -105,8 +129,8 @@ static int sch_transaction(struct i2c_adapter *adap) dev_err(&adap->dev, "Error: no response!\n"); } else if (temp & 0x01) { dev_dbg(&adap->dev, "Post complete!\n"); - outb(temp, SMBHSTSTS); - temp = inb(SMBHSTSTS) & 0x07; + sch_io_wr8(sch_smba, SMBHSTSTS, temp); + temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x07; if (temp & 0x06) { /* Completion clear failed */ dev_dbg(&adap->dev, @@ -117,9 +141,9 @@ static int sch_transaction(struct i2c_adapter *adap) dev_dbg(&adap->dev, "No such address.\n"); } dev_dbg(&adap->dev, "Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", - inb(SMBHSTCNT), - inb(SMBHSTCMD), inb(SMBHSTADD), inb(SMBHSTDAT0), - inb(SMBHSTDAT1)); + sch_io_rd8(sch_smba, SMBHSTCNT), sch_io_rd8(sch_smba, SMBHSTCMD), + sch_io_rd8(sch_smba, SMBHSTADD), + sch_io_rd8(sch_smba, SMBHSTDAT0), sch_io_rd8(sch_smba, SMBHSTDAT1)); return result; } @@ -137,12 +161,12 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, int i, len, temp, rc; /* Make sure the SMBus host is not busy */ - temp = inb(SMBHSTSTS) & 0x0f; + temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; if (temp & 0x08) { dev_dbg(&adap->dev, "SMBus busy (%02x)\n", temp); return -EAGAIN; } - temp = inw(SMBHSTCLK); + temp = sch_io_rd16(sch_smba, SMBHSTCLK); if (!temp) { /* * We can't determine if we have 33 or 25 MHz clock for @@ -151,47 +175,47 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, * run ~75 kHz instead which should do no harm. */ dev_notice(&adap->dev, "Clock divider uninitialized. Setting defaults\n"); - outw(backbone_speed / (4 * 100), SMBHSTCLK); + sch_io_wr16(sch_smba, SMBHSTCLK, backbone_speed / (4 * 100)); } dev_dbg(&adap->dev, "access size: %d %s\n", size, str_read_write(read_write)); switch (size) { case I2C_SMBUS_QUICK: - outb((addr << 1) | read_write, SMBHSTADD); + sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); size = SCH_QUICK; break; case I2C_SMBUS_BYTE: - outb((addr << 1) | read_write, SMBHSTADD); + sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); if (read_write == I2C_SMBUS_WRITE) - outb(command, SMBHSTCMD); + sch_io_wr8(sch_smba, SMBHSTCMD, command); size = SCH_BYTE; break; case I2C_SMBUS_BYTE_DATA: - outb((addr << 1) | read_write, SMBHSTADD); - outb(command, SMBHSTCMD); + sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); + sch_io_wr8(sch_smba, SMBHSTCMD, command); if (read_write == I2C_SMBUS_WRITE) - outb(data->byte, SMBHSTDAT0); + sch_io_wr8(sch_smba, SMBHSTDAT0, data->byte); size = SCH_BYTE_DATA; break; case I2C_SMBUS_WORD_DATA: - outb((addr << 1) | read_write, SMBHSTADD); - outb(command, SMBHSTCMD); + sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); + sch_io_wr8(sch_smba, SMBHSTCMD, command); if (read_write == I2C_SMBUS_WRITE) { - outb(data->word & 0xff, SMBHSTDAT0); - outb((data->word & 0xff00) >> 8, SMBHSTDAT1); + sch_io_wr8(sch_smba, SMBHSTDAT0, data->word >> 0); + sch_io_wr8(sch_smba, SMBHSTDAT1, data->word >> 8); } size = SCH_WORD_DATA; break; case I2C_SMBUS_BLOCK_DATA: - outb((addr << 1) | read_write, SMBHSTADD); - outb(command, SMBHSTCMD); + sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); + sch_io_wr8(sch_smba, SMBHSTCMD, command); if (read_write == I2C_SMBUS_WRITE) { len = data->block[0]; if (len == 0 || len > I2C_SMBUS_BLOCK_MAX) return -EINVAL; - outb(len, SMBHSTDAT0); + sch_io_wr8(sch_smba, SMBHSTDAT0, len); for (i = 1; i <= len; i++) - outb(data->block[i], SMBBLKDAT+i-1); + sch_io_wr8(sch_smba, SMBBLKDAT + i - 1, data->block[i]); } size = SCH_BLOCK_DATA; break; @@ -200,7 +224,10 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, return -EOPNOTSUPP; } dev_dbg(&adap->dev, "write size %d to 0x%04x\n", size, SMBHSTCNT); - outb((inb(SMBHSTCNT) & 0xb0) | (size & 0x7), SMBHSTCNT); + + temp = sch_io_rd8(sch_smba, SMBHSTCNT); + temp = (temp & 0xb0) | (size & 0x7); + sch_io_wr8(sch_smba, SMBHSTCNT, temp); rc = sch_transaction(adap); if (rc) /* Error in transaction */ @@ -212,17 +239,18 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, switch (size) { case SCH_BYTE: case SCH_BYTE_DATA: - data->byte = inb(SMBHSTDAT0); + data->byte = sch_io_rd8(sch_smba, SMBHSTDAT0); break; case SCH_WORD_DATA: - data->word = inb(SMBHSTDAT0) + (inb(SMBHSTDAT1) << 8); + data->word = (sch_io_rd8(sch_smba, SMBHSTDAT0) << 0) + + (sch_io_rd8(sch_smba, SMBHSTDAT1) << 8); break; case SCH_BLOCK_DATA: - data->block[0] = inb(SMBHSTDAT0); + data->block[0] = sch_io_rd8(sch_smba, SMBHSTDAT0); if (data->block[0] == 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX) return -EPROTO; for (i = 1; i <= data->block[0]; i++) - data->block[i] = inb(SMBBLKDAT+i-1); + data->block[i] = sch_io_rd8(sch_smba, SMBBLKDAT + i - 1); break; } return 0; @@ -255,26 +283,21 @@ static int smbus_sch_probe(struct platform_device *dev) if (!res) return -EBUSY; - if (!devm_request_region(&dev->dev, res->start, resource_size(res), - dev->name)) { - dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", - sch_smba); + sch_smba = devm_ioport_map(&dev->dev, res->start, resource_size(res)); + if (!sch_smba) { + dev_err(&dev->dev, "SMBus region %pR already in use!\n", res); return -EBUSY; } - sch_smba = res->start; - - dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); - /* set up the sysfs linkage to our parent device */ sch_adapter.dev.parent = &dev->dev; snprintf(sch_adapter.name, sizeof(sch_adapter.name), - "SMBus SCH adapter at %04x", sch_smba); + "SMBus SCH adapter at %04x", (unsigned short)res->start); retval = i2c_add_adapter(&sch_adapter); if (retval) - sch_smba = 0; + sch_smba = NULL; return retval; } @@ -283,7 +306,7 @@ static void smbus_sch_remove(struct platform_device *pdev) { if (sch_smba) { i2c_del_adapter(&sch_adapter); - sch_smba = 0; + sch_smba = NULL; } } From patchwork Mon Sep 16 12:01:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986088 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=PchLsjXn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6785-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k7p1Kzcz1y1C for ; Mon, 16 Sep 2024 22:03:02 +1000 (AEST) 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 ECA3B1F23359 for ; Mon, 16 Sep 2024 12:02:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31AEC15575B; Mon, 16 Sep 2024 12:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PchLsjXn" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 E59101534FB; Mon, 16 Sep 2024 12:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488166; cv=none; b=E99qtG04P4bI9og7eOTSHR5mrB/yk3K8wTrZ8t/KYe50FM0cUgHpGrDZXvUsXjxxksfpLuWrozjRN7zlM2kUcAiEJd4kvymmhLG9gxJm1sd4VyMCZjhsJZ6HjtWLRoUEXPSPjbUm7uQxOlUu+90fws2WGA2rs29JGoXmQuT++I4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488166; c=relaxed/simple; bh=bg+I4h26eEN07R1ULIoAgV/yRpIEuUkmcm070Rw0j+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fd9YiVQ1RXJA+l557TGydnW/2zXl9YcwJOFsd1gqsx9tjm1SoGG1gUQ+5rz4dcOdxHn0u3tpUjxNS9U1cBOqc1QyEn0p480M0cRTOPAiBzQMsavMKzQ8eMTfj5Z1HjuJBvS5CapUGnm7yKYD0d30yBMSlfKsHdWPWxM6wuDnrvw= 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=PchLsjXn; arc=none smtp.client-ip=192.198.163.19 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=1726488165; x=1758024165; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bg+I4h26eEN07R1ULIoAgV/yRpIEuUkmcm070Rw0j+U=; b=PchLsjXnMc32ZgrCjwTo40cjSVOh/fLsKhsdOJoXdN6MkMRbCpcK5XBD lm2Zfu0zxwtZPO5JyNBMlzWJehIWpsMEzLCzR4Woj29YO6GyMXHPngDyb 7WEMd2gigGMJ9o7qjz+9yj+68xu4tt6NcCTFWqbDNT8CPe8aJ1q5g60+q 6/FkmrMR6dj4mu3a7PhJCCw5qXJo0EDkxbo+4WmM4CKzTdBMIeGItooR3 E9Leeiu3fDjUyMABAT4NL5AYWn4Vnlv0BPeubTmJYiwKYcmw6Q6mWMtZ2 sgIn4irLiRazWTYYTaLaK0q6ai8UWC+RKXVQWj2ntaDR+MMP5+pKIOqPn g==; X-CSE-ConnectionGUID: Q4KyiO4LQuOGXuyvHunedg== X-CSE-MsgGUID: nwPwNgkARsCYC00A+IPslQ== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="24842801" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="24842801" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:42 -0700 X-CSE-ConnectionGUID: Jv2DB1rHSu2/4KDueRfcuA== X-CSE-MsgGUID: SrSY0GEYS3mUGyTEaFKcJA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="68540772" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 16 Sep 2024 05:02:39 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id CBCCC64A; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 04/11] i2c: isch: Use custom private data structure Date: Mon, 16 Sep 2024 15:01:31 +0300 Message-ID: <20240916120237.1385982-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use custom private data structure instead of global variables. With that, remove not anymore true comment. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 145 ++++++++++++++++++---------------- 1 file changed, 75 insertions(+), 70 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index 0eaefb7b8bca..0fe7c9d1dd0d 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -9,16 +9,14 @@ */ -/* - Supports: - Intel SCH chipsets (AF82US15W, AF82US15L, AF82UL11L) - Note: we assume there can only be one device, with one SMBus interface. -*/ +/* Supports: Intel SCH chipsets (AF82US15W, AF82US15L, AF82UL11L) */ #include #include #include +#include #include +#include #include #include #include @@ -46,31 +44,33 @@ #define SCH_WORD_DATA 0x03 #define SCH_BLOCK_DATA 0x05 -static struct i2c_adapter sch_adapter; -static void __iomem *sch_smba; +struct sch_i2c { + struct i2c_adapter adapter; + void __iomem *smba; +}; static int backbone_speed = 33000; /* backbone speed in kHz */ module_param(backbone_speed, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(backbone_speed, "Backbone speed in kHz, (default = 33000)"); -static inline u8 sch_io_rd8(void __iomem *smba, unsigned int offset) +static inline u8 sch_io_rd8(struct sch_i2c *priv, unsigned int offset) { - return ioread8(smba + offset); + return ioread8(priv->smba + offset); } -static inline void sch_io_wr8(void __iomem *smba, unsigned int offset, u8 value) +static inline void sch_io_wr8(struct sch_i2c *priv, unsigned int offset, u8 value) { - iowrite8(value, smba + offset); + iowrite8(value, priv->smba + offset); } -static inline u16 sch_io_rd16(void __iomem *smba, unsigned int offset) +static inline u16 sch_io_rd16(struct sch_i2c *priv, unsigned int offset) { - return ioread16(smba + offset); + return ioread16(priv->smba + offset); } -static inline void sch_io_wr16(void __iomem *smba, unsigned int offset, u16 value) +static inline void sch_io_wr16(struct sch_i2c *priv, unsigned int offset, u16 value) { - iowrite16(value, smba + offset); + iowrite16(value, priv->smba + offset); } /* @@ -80,26 +80,27 @@ static inline void sch_io_wr16(void __iomem *smba, unsigned int offset, u16 valu */ static int sch_transaction(struct i2c_adapter *adap) { + struct sch_i2c *priv = container_of(adap, struct sch_i2c, adapter); int temp; int result = 0; int retries = 0; dev_dbg(&adap->dev, "Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", - sch_io_rd8(sch_smba, SMBHSTCNT), sch_io_rd8(sch_smba, SMBHSTCMD), - sch_io_rd8(sch_smba, SMBHSTADD), - sch_io_rd8(sch_smba, SMBHSTDAT0), sch_io_rd8(sch_smba, SMBHSTDAT1)); + sch_io_rd8(priv, SMBHSTCNT), sch_io_rd8(priv, SMBHSTCMD), + sch_io_rd8(priv, SMBHSTADD), + sch_io_rd8(priv, SMBHSTDAT0), sch_io_rd8(priv, SMBHSTDAT1)); /* Make sure the SMBus host is ready to start transmitting */ - temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; + temp = sch_io_rd8(priv, SMBHSTSTS) & 0x0f; if (temp) { /* Can not be busy since we checked it in sch_access */ if (temp & 0x01) dev_dbg(&adap->dev, "Completion (%02x). Clear...\n", temp); if (temp & 0x06) dev_dbg(&adap->dev, "SMBus error (%02x). Resetting...\n", temp); - sch_io_wr8(sch_smba, SMBHSTSTS, temp); - temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; + sch_io_wr8(priv, SMBHSTSTS, temp); + temp = sch_io_rd8(priv, SMBHSTSTS) & 0x0f; if (temp) { dev_err(&adap->dev, "SMBus is not ready: (%02x)\n", temp); return -EAGAIN; @@ -107,13 +108,13 @@ static int sch_transaction(struct i2c_adapter *adap) } /* start the transaction by setting bit 4 */ - temp = sch_io_rd8(sch_smba, SMBHSTCNT); + temp = sch_io_rd8(priv, SMBHSTCNT); temp |= 0x10; - sch_io_wr8(sch_smba, SMBHSTCNT, temp); + sch_io_wr8(priv, SMBHSTCNT, temp); do { usleep_range(100, 200); - temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; + temp = sch_io_rd8(priv, SMBHSTSTS) & 0x0f; } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); /* If the SMBus is still busy, we give up */ @@ -129,8 +130,8 @@ static int sch_transaction(struct i2c_adapter *adap) dev_err(&adap->dev, "Error: no response!\n"); } else if (temp & 0x01) { dev_dbg(&adap->dev, "Post complete!\n"); - sch_io_wr8(sch_smba, SMBHSTSTS, temp); - temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x07; + sch_io_wr8(priv, SMBHSTSTS, temp); + temp = sch_io_rd8(priv, SMBHSTSTS) & 0x07; if (temp & 0x06) { /* Completion clear failed */ dev_dbg(&adap->dev, @@ -141,9 +142,9 @@ static int sch_transaction(struct i2c_adapter *adap) dev_dbg(&adap->dev, "No such address.\n"); } dev_dbg(&adap->dev, "Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", - sch_io_rd8(sch_smba, SMBHSTCNT), sch_io_rd8(sch_smba, SMBHSTCMD), - sch_io_rd8(sch_smba, SMBHSTADD), - sch_io_rd8(sch_smba, SMBHSTDAT0), sch_io_rd8(sch_smba, SMBHSTDAT1)); + sch_io_rd8(priv, SMBHSTCNT), sch_io_rd8(priv, SMBHSTCMD), + sch_io_rd8(priv, SMBHSTADD), + sch_io_rd8(priv, SMBHSTDAT0), sch_io_rd8(priv, SMBHSTDAT1)); return result; } @@ -158,15 +159,16 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data) { + struct sch_i2c *priv = container_of(adap, struct sch_i2c, adapter); int i, len, temp, rc; /* Make sure the SMBus host is not busy */ - temp = sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; + temp = sch_io_rd8(priv, SMBHSTSTS) & 0x0f; if (temp & 0x08) { dev_dbg(&adap->dev, "SMBus busy (%02x)\n", temp); return -EAGAIN; } - temp = sch_io_rd16(sch_smba, SMBHSTCLK); + temp = sch_io_rd16(priv, SMBHSTCLK); if (!temp) { /* * We can't determine if we have 33 or 25 MHz clock for @@ -175,47 +177,47 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, * run ~75 kHz instead which should do no harm. */ dev_notice(&adap->dev, "Clock divider uninitialized. Setting defaults\n"); - sch_io_wr16(sch_smba, SMBHSTCLK, backbone_speed / (4 * 100)); + sch_io_wr16(priv, SMBHSTCLK, backbone_speed / (4 * 100)); } dev_dbg(&adap->dev, "access size: %d %s\n", size, str_read_write(read_write)); switch (size) { case I2C_SMBUS_QUICK: - sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); + sch_io_wr8(priv, SMBHSTADD, (addr << 1) | read_write); size = SCH_QUICK; break; case I2C_SMBUS_BYTE: - sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); + sch_io_wr8(priv, SMBHSTADD, (addr << 1) | read_write); if (read_write == I2C_SMBUS_WRITE) - sch_io_wr8(sch_smba, SMBHSTCMD, command); + sch_io_wr8(priv, SMBHSTCMD, command); size = SCH_BYTE; break; case I2C_SMBUS_BYTE_DATA: - sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); - sch_io_wr8(sch_smba, SMBHSTCMD, command); + sch_io_wr8(priv, SMBHSTADD, (addr << 1) | read_write); + sch_io_wr8(priv, SMBHSTCMD, command); if (read_write == I2C_SMBUS_WRITE) - sch_io_wr8(sch_smba, SMBHSTDAT0, data->byte); + sch_io_wr8(priv, SMBHSTDAT0, data->byte); size = SCH_BYTE_DATA; break; case I2C_SMBUS_WORD_DATA: - sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); - sch_io_wr8(sch_smba, SMBHSTCMD, command); + sch_io_wr8(priv, SMBHSTADD, (addr << 1) | read_write); + sch_io_wr8(priv, SMBHSTCMD, command); if (read_write == I2C_SMBUS_WRITE) { - sch_io_wr8(sch_smba, SMBHSTDAT0, data->word >> 0); - sch_io_wr8(sch_smba, SMBHSTDAT1, data->word >> 8); + sch_io_wr8(priv, SMBHSTDAT0, data->word >> 0); + sch_io_wr8(priv, SMBHSTDAT1, data->word >> 8); } size = SCH_WORD_DATA; break; case I2C_SMBUS_BLOCK_DATA: - sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); - sch_io_wr8(sch_smba, SMBHSTCMD, command); + sch_io_wr8(priv, SMBHSTADD, (addr << 1) | read_write); + sch_io_wr8(priv, SMBHSTCMD, command); if (read_write == I2C_SMBUS_WRITE) { len = data->block[0]; if (len == 0 || len > I2C_SMBUS_BLOCK_MAX) return -EINVAL; - sch_io_wr8(sch_smba, SMBHSTDAT0, len); + sch_io_wr8(priv, SMBHSTDAT0, len); for (i = 1; i <= len; i++) - sch_io_wr8(sch_smba, SMBBLKDAT + i - 1, data->block[i]); + sch_io_wr8(priv, SMBBLKDAT + i - 1, data->block[i]); } size = SCH_BLOCK_DATA; break; @@ -225,9 +227,9 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, } dev_dbg(&adap->dev, "write size %d to 0x%04x\n", size, SMBHSTCNT); - temp = sch_io_rd8(sch_smba, SMBHSTCNT); + temp = sch_io_rd8(priv, SMBHSTCNT); temp = (temp & 0xb0) | (size & 0x7); - sch_io_wr8(sch_smba, SMBHSTCNT, temp); + sch_io_wr8(priv, SMBHSTCNT, temp); rc = sch_transaction(adap); if (rc) /* Error in transaction */ @@ -239,18 +241,18 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr, switch (size) { case SCH_BYTE: case SCH_BYTE_DATA: - data->byte = sch_io_rd8(sch_smba, SMBHSTDAT0); + data->byte = sch_io_rd8(priv, SMBHSTDAT0); break; case SCH_WORD_DATA: - data->word = (sch_io_rd8(sch_smba, SMBHSTDAT0) << 0) + - (sch_io_rd8(sch_smba, SMBHSTDAT1) << 8); + data->word = (sch_io_rd8(priv, SMBHSTDAT0) << 0) + + (sch_io_rd8(priv, SMBHSTDAT1) << 8); break; case SCH_BLOCK_DATA: - data->block[0] = sch_io_rd8(sch_smba, SMBHSTDAT0); + data->block[0] = sch_io_rd8(priv, SMBHSTDAT0); if (data->block[0] == 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX) return -EPROTO; for (i = 1; i <= data->block[0]; i++) - data->block[i] = sch_io_rd8(sch_smba, SMBBLKDAT + i - 1); + data->block[i] = sch_io_rd8(priv, SMBBLKDAT + i - 1); break; } return 0; @@ -268,46 +270,49 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = sch_func, }; -static struct i2c_adapter sch_adapter = { - .owner = THIS_MODULE, - .class = I2C_CLASS_HWMON, - .algo = &smbus_algorithm, -}; - static int smbus_sch_probe(struct platform_device *dev) { + struct sch_i2c *priv; struct resource *res; int retval; + priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + res = platform_get_resource(dev, IORESOURCE_IO, 0); if (!res) return -EBUSY; - sch_smba = devm_ioport_map(&dev->dev, res->start, resource_size(res)); - if (!sch_smba) { + priv->smba = devm_ioport_map(&dev->dev, res->start, resource_size(res)); + if (!priv->smba) { dev_err(&dev->dev, "SMBus region %pR already in use!\n", res); return -EBUSY; } /* set up the sysfs linkage to our parent device */ - sch_adapter.dev.parent = &dev->dev; + priv->adapter.dev.parent = &dev->dev; + priv->adapter.owner = THIS_MODULE, + priv->adapter.class = I2C_CLASS_HWMON, + priv->adapter.algo = &smbus_algorithm, - snprintf(sch_adapter.name, sizeof(sch_adapter.name), + snprintf(priv->adapter.name, sizeof(priv->adapter.name), "SMBus SCH adapter at %04x", (unsigned short)res->start); - retval = i2c_add_adapter(&sch_adapter); + retval = i2c_add_adapter(&priv->adapter); if (retval) - sch_smba = NULL; + return retval; - return retval; + platform_set_drvdata(dev, priv); + + return 0; } static void smbus_sch_remove(struct platform_device *pdev) { - if (sch_smba) { - i2c_del_adapter(&sch_adapter); - sch_smba = NULL; - } + struct sch_i2c *priv = platform_get_drvdata(pdev); + + i2c_del_adapter(&priv->adapter); } static struct platform_driver smbus_sch_driver = { From patchwork Mon Sep 16 12:01:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986096 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=S0J/rmvg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6793-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k9g0RXRz1y1C for ; Mon, 16 Sep 2024 22:04:39 +1000 (AEST) 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4AEB11C22F7A for ; Mon, 16 Sep 2024 12:04:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2902815A849; Mon, 16 Sep 2024 12: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="S0J/rmvg" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 2893B158DA9; Mon, 16 Sep 2024 12:02:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488175; cv=none; b=QdTCr83KbW3yio4unXIxel90W7srGlKmQuki9Rd3PnFJlA7EXDX7xuiSjt2zuBHp5RVzoIi3WkGW2ekqu4qaKC+mdZl9eYpCbu91BGMe+1SiuiKD3d8cMwRMS15Xn96/jEVgRl7+xdBIbtTtuFDt3D1bEtGlyyfiAG/zElXB6ZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488175; c=relaxed/simple; bh=c5+EyVZusvXwwP0Tmd8F3Ep5LHjkNJvOIHH43dXMK4U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BsZ3ySy+0SrBb/whFgbmCSKFtDyU+tNmTOzC5JtfxR4Ggdq0PJHgrEKXlAN4ynpNa+giuyXIEh4GWwz06xmFATCz8MdlLIBoqTj+DkhN+0ZbPxPJpO/rhfZv7S4r40sSgjHUWPmYB0BiubGmgtNfuyvHemQcvJiDCYKFxLHJqE8= 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=S0J/rmvg; arc=none smtp.client-ip=192.198.163.7 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=1726488174; x=1758024174; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c5+EyVZusvXwwP0Tmd8F3Ep5LHjkNJvOIHH43dXMK4U=; b=S0J/rmvg4Ktujik3BWSfhPo+jMFYMwADsItVgpTuvxh4SshkWAjOSmHz BcKofOz7lrCkJ3QqyjiZZeCOQFj1kim+4IwPrfY4zM+m0wuTFIjHOmt+N XY/+nBVXnuBUSJrHe0QnwAm4mXWomQ0ihFZrOQz7/zP9l1ME1eAt22ZuU sgto6Z4dhruchWvvPlofbR0teqj/Jlap4W5Wbi3JwQZIVSKPrQUtFegSv ZgvDHY9lykn9hFOgks7JruEcr1jlpbSW43N53X96HNDcAop/qjOx/S/CG pM0FJoIOqKWAq8sDVOehTSy8K6gRckRuCoIjbqU+BH6LSvzRPui7XBabW A==; X-CSE-ConnectionGUID: Pw8A1R08TWK9hNxzDnqMgg== X-CSE-MsgGUID: 5Fbh+tCCQFaudQujCxEfOQ== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="50725484" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="50725484" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:44 -0700 X-CSE-ConnectionGUID: P/x+kd2hQv+kd0MZQBGRjA== X-CSE-MsgGUID: 51NcZdhbT9S+Pns/Z5Apzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="72939892" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa003.fm.intel.com with ESMTP; 16 Sep 2024 05:02:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D2827668; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 05/11] i2c: isch: switch i2c registration to devm functions Date: Mon, 16 Sep 2024 15:01:32 +0300 Message-ID: <20240916120237.1385982-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Switch from i2c_add_adapter() to resource managed devm_i2c_add_adapter() for matching rest of driver initialization, and more concise code. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index 0fe7c9d1dd0d..d752f822b52e 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -274,7 +274,6 @@ static int smbus_sch_probe(struct platform_device *dev) { struct sch_i2c *priv; struct resource *res; - int retval; priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -299,20 +298,7 @@ static int smbus_sch_probe(struct platform_device *dev) snprintf(priv->adapter.name, sizeof(priv->adapter.name), "SMBus SCH adapter at %04x", (unsigned short)res->start); - retval = i2c_add_adapter(&priv->adapter); - if (retval) - return retval; - - platform_set_drvdata(dev, priv); - - return 0; -} - -static void smbus_sch_remove(struct platform_device *pdev) -{ - struct sch_i2c *priv = platform_get_drvdata(pdev); - - i2c_del_adapter(&priv->adapter); + return devm_i2c_add_adapter(&dev->dev, &priv->adapter); } static struct platform_driver smbus_sch_driver = { @@ -320,7 +306,6 @@ static struct platform_driver smbus_sch_driver = { .name = "isch_smbus", }, .probe = smbus_sch_probe, - .remove_new = smbus_sch_remove, }; module_platform_driver(smbus_sch_driver); From patchwork Mon Sep 16 12:01:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986095 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UmWCXMuB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6792-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k9Z4t8zz1y1C for ; Mon, 16 Sep 2024 22:04:34 +1000 (AEST) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 33A9528140F for ; Mon, 16 Sep 2024 12:04:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C23C7156F4A; Mon, 16 Sep 2024 12:02:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UmWCXMuB" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 EB25E15957E; Mon, 16 Sep 2024 12:02:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488175; cv=none; b=mfnbluAu+I1hjTTdUx9mR3hhR2vVxMq1zIZFHalXDSbAz+sppXON+cGKrLLvGhIIiMJTzh2b34GyI0nsIbddhBpMkiAvZ8qlGkX9m4fyd1flV9PprGkZozCdkVquei6XD0ybS/GpnPzkVPVSLxzpxqhHBoMnzFHwOPXGTdJm3KE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488175; c=relaxed/simple; bh=MhAXVGI/Kzt0oL8qizf5tKDuT6I9gfAbGpp8ziDudqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MUtIB0M3yhN2XeiYGlx4BZ2w+XUrUlkMweFGHBP7Li8ckCcX1yPz5+0Ac7E1x0lV9Aon370d9T2iaGraUfD895VYsotiLcSVCKarSOV3JVSxov6hvpoeV1B1eobe14HXFt2DlaEPAQZY0nUgWaYXq0EoW22GiR0Uag/G7diOTnM= 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=UmWCXMuB; arc=none smtp.client-ip=192.198.163.7 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=1726488174; x=1758024174; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MhAXVGI/Kzt0oL8qizf5tKDuT6I9gfAbGpp8ziDudqU=; b=UmWCXMuBxRVogJsXJCxfmryzBcfyfj2//7HNOuc3vZWfXbBTr6RcXhTi If42wOjDuNFyKx7TwP6N7DB4uMVvzQGW0s4f/Q+DE5Kk76MO8ZufH+z+/ ZicejrCl3TO/+mac092pQz7GOvoJ9CcFbF2fEVW/PQUR1iFQfFt3TLRnH o/5DLGjowXVPrva+08diWA2gETj/HoGwGiwPrKKyVkZ7MCuUfr+jK8E71 J/LnUdM/+Y+DecIlvr8DGUR6qObj0oySxRSRGlrb+b1VsWtDeRvjazjzV pnE7Xp8SpOqHOcOyqsf7gClmbGxAbTTlbIe+qMkIO6MeBRXWPMKeaqFjI g==; X-CSE-ConnectionGUID: KeGQESnSSyWV/5+ksNtgqA== X-CSE-MsgGUID: d664qhjXSNWwV7/mIHUpWw== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="50725479" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="50725479" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:44 -0700 X-CSE-ConnectionGUID: EFF8sJwbQNyeKVH/6oEr/A== X-CSE-MsgGUID: hKnn7488QvC5IFtOeJKyqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="72939893" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa003.fm.intel.com with ESMTP; 16 Sep 2024 05:02:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D94CD66C; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 06/11] i2c: isch: Utilize temporary variable to hold device pointer Date: Mon, 16 Sep 2024 15:01:33 +0300 Message-ID: <20240916120237.1385982-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce a temporary variable to hold a device pointer. It can be utilized in the ->probe() and save a bit of LoCs. To make it consistent, rename currently used dev to pdev. While at it, convert the only error message to dev_err_probe(). Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index d752f822b52e..d0098b7139a0 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -270,27 +270,26 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = sch_func, }; -static int smbus_sch_probe(struct platform_device *dev) +static int smbus_sch_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct sch_i2c *priv; struct resource *res; - priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; - res = platform_get_resource(dev, IORESOURCE_IO, 0); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res) return -EBUSY; - priv->smba = devm_ioport_map(&dev->dev, res->start, resource_size(res)); - if (!priv->smba) { - dev_err(&dev->dev, "SMBus region %pR already in use!\n", res); - return -EBUSY; - } + priv->smba = devm_ioport_map(dev, res->start, resource_size(res)); + if (!priv->smba) + return dev_err_probe(dev, -EBUSY, "SMBus region %pR already in use!\n", res); /* set up the sysfs linkage to our parent device */ - priv->adapter.dev.parent = &dev->dev; + priv->adapter.dev.parent = dev; priv->adapter.owner = THIS_MODULE, priv->adapter.class = I2C_CLASS_HWMON, priv->adapter.algo = &smbus_algorithm, @@ -298,7 +297,7 @@ static int smbus_sch_probe(struct platform_device *dev) snprintf(priv->adapter.name, sizeof(priv->adapter.name), "SMBus SCH adapter at %04x", (unsigned short)res->start); - return devm_i2c_add_adapter(&dev->dev, &priv->adapter); + return devm_i2c_add_adapter(dev, &priv->adapter); } static struct platform_driver smbus_sch_driver = { From patchwork Mon Sep 16 12:01:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986092 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=KDWAeeJL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6789-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k8R69Cxz1y1C for ; Mon, 16 Sep 2024 22:03:35 +1000 (AEST) 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 11174B2293B for ; Mon, 16 Sep 2024 12:03:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE55F158525; Mon, 16 Sep 2024 12:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KDWAeeJL" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 D7C2D156C5F; Mon, 16 Sep 2024 12:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488169; cv=none; b=GG16hs/gS4pMXNK5P0EKEbQ2c/3JJu5WZi8ODbMPKvIf7+yXHNIfp+2dpKqCrdSw8BwMYStubwo/McygxoQls06/CQkLYWzeB9Q1diRWP1CBkvgFrZ2OdcBEUZiQixpY3/StlIrSqU+nFZmSK8Wt1bFx7BYZBHPFI6tdllglCuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488169; c=relaxed/simple; bh=yPXkWpV/o+wi6jClcgywPYyS6yUsGonyYmuAXlI/UB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BWvy3QA1kk3sdpdbHvLuFhK4VacQtPP2K8tS3fmx8Wv3Xh0IH6y+tarLlqCDoyC2eJwgG+bpjBVcJoOfDT8cRTp5ZfeGV8CQ3m+gwZgUhUP9cXVEQePzddH7IDUG3opIoMnIUHrQU9LxdmTxvpKO0kF7rJjIH+MXN7tXYr0TEo0= 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=KDWAeeJL; arc=none smtp.client-ip=192.198.163.19 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=1726488168; x=1758024168; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yPXkWpV/o+wi6jClcgywPYyS6yUsGonyYmuAXlI/UB4=; b=KDWAeeJLX1J+9sfgHXS76P4b91KCp96BRCJhCL0ihFLQpodMQMUfH0fX fC1GMqpbxOY4cbRx27ThsiwRxnox4epoL4YrWrkANSqK0rLwIdxhX6ZGT l6uGjkKqKDLA1JF5nHowDOvCt0LH4M7hM/C3rRF/ehlbBNIb4MAB2g+lZ w7I5GlfrVCGxNYIirNaeosyXSrhTs96ukiBcolRamQ7qXR/yBMoDTyj8w 3hCfE6CwYry3XADh53lnRw63NUtYjFkWnD12ljaDPUR8frnWqCcI1GaNL gKr1FQq864odMeFIbf+qbO1je3kn1fUB9GkPeNZBY0PftEQM0gWYwRwG6 w==; X-CSE-ConnectionGUID: LMj70TkVSju9JOE7ihcgJQ== X-CSE-MsgGUID: mhxOsu+CQ0ehi/0VHqZRYw== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="24842824" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="24842824" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:44 -0700 X-CSE-ConnectionGUID: fIL4VNWrSpedNTVlJX2i1Q== X-CSE-MsgGUID: IGHl9Vk1RFWwkmjHBazNmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="68540778" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 16 Sep 2024 05:02:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E17C567E; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 07/11] i2c: isch: Use read_poll_timeout() Date: Mon, 16 Sep 2024 15:01:34 +0300 Message-ID: <20240916120237.1385982-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Simplify the code by using read_poll_timeout(). Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index d0098b7139a0..e6b99913f4f3 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -17,9 +17,9 @@ #include #include #include -#include #include -#include +#include +#include #include #include #include @@ -34,9 +34,6 @@ #define SMBHSTDAT1 0x07 #define SMBBLKDAT 0x20 -/* Other settings */ -#define MAX_RETRIES 5000 - /* I2C constants */ #define SCH_QUICK 0x00 #define SCH_BYTE 0x01 @@ -83,7 +80,6 @@ static int sch_transaction(struct i2c_adapter *adap) struct sch_i2c *priv = container_of(adap, struct sch_i2c, adapter); int temp; int result = 0; - int retries = 0; dev_dbg(&adap->dev, "Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", @@ -112,15 +108,11 @@ static int sch_transaction(struct i2c_adapter *adap) temp |= 0x10; sch_io_wr8(priv, SMBHSTCNT, temp); - do { - usleep_range(100, 200); - temp = sch_io_rd8(priv, SMBHSTSTS) & 0x0f; - } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); - + result = read_poll_timeout(sch_io_rd8, temp, !(temp & 0x08), 200, 500000, true, + priv, SMBHSTSTS); /* If the SMBus is still busy, we give up */ - if (retries > MAX_RETRIES) { + if (result) { dev_err(&adap->dev, "SMBus Timeout!\n"); - result = -ETIMEDOUT; } else if (temp & 0x04) { result = -EIO; dev_dbg(&adap->dev, "Bus collision! SMBus may be locked until next hard reset. (sorry!)\n"); @@ -130,7 +122,7 @@ static int sch_transaction(struct i2c_adapter *adap) dev_err(&adap->dev, "Error: no response!\n"); } else if (temp & 0x01) { dev_dbg(&adap->dev, "Post complete!\n"); - sch_io_wr8(priv, SMBHSTSTS, temp); + sch_io_wr8(priv, SMBHSTSTS, temp & 0x0f); temp = sch_io_rd8(priv, SMBHSTSTS) & 0x07; if (temp & 0x06) { /* Completion clear failed */ From patchwork Mon Sep 16 12:01:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986093 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Sd6yRg1V; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:4601:e00::3; helo=am.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6790-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k8j0bgWz1y1C for ; Mon, 16 Sep 2024 22:03:49 +1000 (AEST) 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 054831F244B7 for ; Mon, 16 Sep 2024 12:03:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EB1D15855C; Mon, 16 Sep 2024 12:02:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Sd6yRg1V" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 61B0A156F4A; Mon, 16 Sep 2024 12:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488170; cv=none; b=FecSF89zYZ615s2z4BA1TdUYWf4uEKXC5/Y6Is3+BOPCD8VAeaOmXcL9GWC9Q36bUpiB3ARrQgOQZeYU4+QUdN1qfEC5kNXciK2U584clr34B1TiDTfTFsv+Ef7jf49GLIvEVn9B1a/B9Cr0e+vv6v3QzKdfMXCsxHv0j6FkoW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488170; c=relaxed/simple; bh=9lNwwchqtXXJpXOahHD+7ykMGOfbN3/dx2wh9a8nQ90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jMArBCkqnlKKOAe0b4+arzLDBsMTfsIQunQiqtlTYFLM8tdPw9GfBAXx2JHR35qOk9WK8cmpEGu37kYW3GLSFHx+3Img7KRPFl+v9F8oegEuMi2aw8OTn9BekCCYHNgm6/iaO2vNGK7BO2mdWuvOdKvd8BWQ2maig18fHGWXzlc= 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=Sd6yRg1V; arc=none smtp.client-ip=192.198.163.19 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=1726488169; x=1758024169; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9lNwwchqtXXJpXOahHD+7ykMGOfbN3/dx2wh9a8nQ90=; b=Sd6yRg1VZuwdNij5jDHsv3mMFZK0+ywNFvm4cr8TYAaurNa0qPo9spGP CmGkIxb0IYtvikahGZuocFe76e/0jqmhbq9MMje5cqSZ/nOOG6L6MYgu0 xEsanbv/JBJoyUb0IcJY5efCBvh5+pQFJvZbYSl8NCGPos1ttKToyBd9o jLdqzhhTKEuILhSmG1j5wm5m/hWQ0qeFsLAzyAgUB24gHE08IxSJPmxbc /g/RvXsCO66/8fw6MBsmFz08im5HnTTxXTSMzGhqfRQweeM3AQLQJlxea q245egr5rx5KEHLv4X7//mGnqEOW7zvYN/7sUmoHwhAT5rdD/jmMI7AEu w==; X-CSE-ConnectionGUID: jgifz9KZRQuD+m5Xb2q+TA== X-CSE-MsgGUID: DVOI24wlTnKEcYWky14L9g== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="24842832" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="24842832" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:44 -0700 X-CSE-ConnectionGUID: PwQXyc/OQhCHIEDZIyDXHQ== X-CSE-MsgGUID: luRzunH7TnieW1RlhEcngQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="68540780" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 16 Sep 2024 05:02:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E9B44628; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 08/11] i2c: isch: Unify the name of the variable to hold an error code Date: Mon, 16 Sep 2024 15:01:35 +0300 Message-ID: <20240916120237.1385982-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are two different names used for the variable that holds an error code. Unify to use one variant in all cases. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index e6b99913f4f3..d71a42fd9dd9 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -79,7 +79,7 @@ static int sch_transaction(struct i2c_adapter *adap) { struct sch_i2c *priv = container_of(adap, struct sch_i2c, adapter); int temp; - int result = 0; + int rc; dev_dbg(&adap->dev, "Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", @@ -108,17 +108,16 @@ static int sch_transaction(struct i2c_adapter *adap) temp |= 0x10; sch_io_wr8(priv, SMBHSTCNT, temp); - result = read_poll_timeout(sch_io_rd8, temp, !(temp & 0x08), 200, 500000, true, - priv, SMBHSTSTS); + rc = read_poll_timeout(sch_io_rd8, temp, !(temp & 0x08), 200, 500000, true, priv, SMBHSTSTS); /* If the SMBus is still busy, we give up */ - if (result) { + if (rc) { dev_err(&adap->dev, "SMBus Timeout!\n"); } else if (temp & 0x04) { - result = -EIO; + rc = -EIO; dev_dbg(&adap->dev, "Bus collision! SMBus may be locked until next hard reset. (sorry!)\n"); /* Clock stops and target is stuck in mid-transmission */ } else if (temp & 0x02) { - result = -EIO; + rc = -EIO; dev_err(&adap->dev, "Error: no response!\n"); } else if (temp & 0x01) { dev_dbg(&adap->dev, "Post complete!\n"); @@ -130,14 +129,14 @@ static int sch_transaction(struct i2c_adapter *adap) "Failed reset at end of transaction (%02x), Bus error!\n", temp); } } else { - result = -ENXIO; + rc = -ENXIO; dev_dbg(&adap->dev, "No such address.\n"); } dev_dbg(&adap->dev, "Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", sch_io_rd8(priv, SMBHSTCNT), sch_io_rd8(priv, SMBHSTCMD), sch_io_rd8(priv, SMBHSTADD), sch_io_rd8(priv, SMBHSTDAT0), sch_io_rd8(priv, SMBHSTDAT1)); - return result; + return rc; } /* From patchwork Mon Sep 16 12:01:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986090 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UVytRDYQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6787-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k842Ry6z1y1C for ; Mon, 16 Sep 2024 22:03:16 +1000 (AEST) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id ADEE6284EDC for ; Mon, 16 Sep 2024 12:03:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DE16157472; Mon, 16 Sep 2024 12:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UVytRDYQ" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 B818C156237; Mon, 16 Sep 2024 12:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488168; cv=none; b=pLsq+0xZPg07rC9S6Le6iuDTpikwmkYx0zFquTFe+ix+s4PT+KqLmPfL6FpLxCa7baWCMmpndejLaTI7Jv/pZ7XBEyMzIpA2bMcuo3xdTjVUB95jG1loqd20qyzX8+bSJnTQ79jE5xEapTpjPikouomu39kV0PAREbwxYFDB09A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488168; c=relaxed/simple; bh=aL3gCHi3APo2vDRNIL3hkz/MXq651eltciPJzDM06GU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cD0xxMf51C/jpewPLNSJU9EQmUlq+mJZOzhkwp0SYOfgq16u505eBtvDofBnfldJN5S6tn7nvViEf/Qq+mf8IuNVMU+AbiEaGDYS2Nzkyz3hVww0PiBEZKuPBpq9txMA0MdhGKJDBZrSPSogUG8xTAKpC8wR0YAaaz3iyD7oRlM= 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=UVytRDYQ; arc=none smtp.client-ip=192.198.163.19 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=1726488167; x=1758024167; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aL3gCHi3APo2vDRNIL3hkz/MXq651eltciPJzDM06GU=; b=UVytRDYQVh7Bs29AwvokblmLT6fOnTFuWDBxcg5A+vlbnCeh1U5n49Qb afUouYIIVlsLmQFofFIdBgi9MM8XP2hiKV6XanIxWHubz5IB1hekzq59x LSM67OjFm8vCQIPU7Z9ptcs0ZHTLq6OrBeClv8maablKHxZI4+H7yTlq1 nouYav42GcfqDBc+jqogBDDNM/rRo95AQuPVkWO5eqahmOFGDAgAolN/u DxR/8/w2iHzmVakkxkT8lsRZSPQyv//8jKG1L7vqvkrms3AipiGWN7Whx JiSGKu4KmKNdxuvVUoTHz8o7AxGxWI8q75uNyiq1P7g/gVX9LKTUJVaMa g==; X-CSE-ConnectionGUID: vtgbe30MSIC17aZ7PgqQZQ== X-CSE-MsgGUID: c+NZVy1/TumroeXqRLqLxA== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="24842819" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="24842819" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:44 -0700 X-CSE-ConnectionGUID: bl69jk88RZOBUYbkJMIvDw== X-CSE-MsgGUID: 6I/rRm3nQsOIeIN684yRgQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="68540779" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 16 Sep 2024 05:02:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id F406868A; Mon, 16 Sep 2024 15:02:38 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 09/11] i2c: isch: Don't use "proxy" headers Date: Mon, 16 Sep 2024 15:01:36 +0300 Message-ID: <20240916120237.1385982-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Update header inclusions to follow IWYU (Include What You Use) principle. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index d71a42fd9dd9..1a18a276a857 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -11,15 +11,17 @@ /* Supports: Intel SCH chipsets (AF82US15W, AF82US15L, AF82UL11L) */ -#include -#include -#include #include #include #include +#include +#include #include #include #include +#include +#include +#include #include #include #include From patchwork Mon Sep 16 12:01:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986097 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UCt4DuEM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6794-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k9y3Zs1z1y1C for ; Mon, 16 Sep 2024 22:04:54 +1000 (AEST) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 47915284432 for ; Mon, 16 Sep 2024 12:04:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83F3C15AD8B; Mon, 16 Sep 2024 12:02:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UCt4DuEM" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 95AAE1598EE; Mon, 16 Sep 2024 12:02:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488177; cv=none; b=SSxlwL8nudqc3Rau8Bwr/eXoeUcp3/gPMzXEUTJeRVVIxQeIDYaqgtYodnoaOaIfMyzvQRUeQcrvSLidlHMMZgeqgLafVVSgX4uB25AirUG70sanOsBgeCa+G50WO2Wx2MlmOEpOE+LmsP/bHg/eySjVnbO8M1r9lp/HqlODKJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488177; c=relaxed/simple; bh=tYYLqHDhvAMug+JLroLRFL/8xmd21D9xE2RL7OIZZnE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nWgPwaoZVAWQ+ZcShNd7w6MwVeRPIHZpcR5sk91ogQTQ1iVEnSiaQON+/YDvI4ayFYQeJl8k1bIT4XADP3aoGP+7strlUB+00l7fZZzBZtEcl//3k6sLxOAvM9Z7zHMeE93NUDOAUow1XCwG9G8ydHXQ9up+q2Xi4svyP+O+Afw= 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=UCt4DuEM; arc=none smtp.client-ip=192.198.163.7 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=1726488175; x=1758024175; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tYYLqHDhvAMug+JLroLRFL/8xmd21D9xE2RL7OIZZnE=; b=UCt4DuEMMHwbT/K5L865gApLZCZ2xnpaSivJYiXXf3iRmSLwHi+nk8TJ sSiwa2sI0NSWT75YlhiQHySFXFfGul0jmE7hMEitXgqGsL1UUH+zzc60o 3PoUFLygFaCh88p6j6bDRnIScOAj+bpKm9Ql4QpWDSHk9QM+PT4I8Cliv g+e7RYlDLx8+Kl2CyVnVpdNwNTRSU12y8HLVNg0mThQgCkPPw9JlAJlnY AdTNFupYLtebZ3j7B1vTFCgmPry+jUmROhKhLuMSZ2XoDQwS30nsikNzu kQEWQmOc1Uktb2tLMxmn+EDSXr6D45oPWawdbKN2tT9HZISe62IxLFDv9 Q==; X-CSE-ConnectionGUID: 5LcR1WvYQB+wska45n4Zog== X-CSE-MsgGUID: M6M9SKWeTui1vYSR7iTW8w== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="50725488" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="50725488" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:44 -0700 X-CSE-ConnectionGUID: hUFkAKh2S4Ga7KZ32PoM7A== X-CSE-MsgGUID: HUEW9ShXSAOy3NIN7Xjw2g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="72939897" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa003.fm.intel.com with ESMTP; 16 Sep 2024 05:02:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 1335E708; Mon, 16 Sep 2024 15:02:39 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 10/11] i2c: isch: Prefer to use octal permission Date: Mon, 16 Sep 2024 15:01:37 +0300 Message-ID: <20240916120237.1385982-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Octal permissions are preferred over the symbolics ones for readbility. This ceases warning message pointed by checkpatch. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index 1a18a276a857..b2857e8e1c58 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -49,7 +49,7 @@ struct sch_i2c { }; static int backbone_speed = 33000; /* backbone speed in kHz */ -module_param(backbone_speed, int, S_IRUSR | S_IWUSR); +module_param(backbone_speed, int, 0600); MODULE_PARM_DESC(backbone_speed, "Backbone speed in kHz, (default = 33000)"); static inline u8 sch_io_rd8(struct sch_i2c *priv, unsigned int offset) From patchwork Mon Sep 16 12:01:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1986091 X-Patchwork-Delegate: andi.shyti@kernel.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=LoUisgIY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-i2c+bounces-6788-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6k8J6vjDz1y1C for ; Mon, 16 Sep 2024 22:03:28 +1000 (AEST) 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 3CC891F24390 for ; Mon, 16 Sep 2024 12:03:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 417471581E1; Mon, 16 Sep 2024 12:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LoUisgIY" X-Original-To: linux-i2c@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 00E8A156654; Mon, 16 Sep 2024 12:02:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488168; cv=none; b=XYYOT/a42GJ3T5cAS2re2aovk1chsqVS7oORbSMpB7+F9v0SrVNLCdzihftr09TJhLH1dBZ8v7tZ1KpqY5CZrYdM1TfxGlVxljnNTf052v4Z5KdN8Oey/ypYZMur0mnipOKJoBL/rF5H7RYAbAr9N+wvBMy4OKQY7eLj+/C+wmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726488168; c=relaxed/simple; bh=rxXnm0azao5yDrOsSuKoukkb1vYMVqWT1uQqrgdp6fQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ANETE/IXtKGYLpiXXnEzWzFYUk/ohhYwhiD7prNVGTfaQbCLmEKNNLWs273VSOTvXQXH+3RrVwyYIhjOClInuKK+RCMkRCTm6fd9mJtc4WO4SXiVK3SG3kwYI9K5a8L/0PE6frSWNyngk0esIVK6sj1p3SCLRUa2ai1Fx5cbEPs= 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=LoUisgIY; arc=none smtp.client-ip=192.198.163.19 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=1726488167; x=1758024167; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rxXnm0azao5yDrOsSuKoukkb1vYMVqWT1uQqrgdp6fQ=; b=LoUisgIYeDQHpD/ibL70FUPvzI5iRWcQCMESByjU23jXafB2hP07u61p jREDhonWXHOccWcNykN+D/8D32O41S4KyLvoN2hOCCteBvNed4JAEytf+ Zd1xD8D76U+yeJR0u5wGlDiMUsotgH2pawF98OtRUkkwvc9XklVGZ/9OF upgg9XV9p3T52dA4Oz795NEGxHNJdEBiLnLWIJMd7irgiqWdgsjZJyfQE gP2/GVV9Un30FJpEWXL+PkBo0oQ1sPlPJqAUhb9zByiWbFZRBNcxgXXgq I7wHyLo4X4A36RekOKCD0n+OripcK1omGUlgSYSQeBgDI2qKQsgPu3Kh2 A==; X-CSE-ConnectionGUID: J+emVUUhQZmwUOEoSh7QaQ== X-CSE-MsgGUID: 4i/JNql5T9iuJkZbTvzUtg== X-IronPort-AV: E=McAfee;i="6700,10204,11196"; a="24842830" X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="24842830" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Sep 2024 05:02:44 -0700 X-CSE-ConnectionGUID: BS3QeiVhQA6GpL68AJenDw== X-CSE-MsgGUID: R8XkRmZ0RuWud+6wmmGTBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,233,1719903600"; d="scan'208";a="68540781" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 16 Sep 2024 05:02:42 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 18C016E5; Mon, 16 Sep 2024 15:02:39 +0300 (EEST) From: Andy Shevchenko To: Andi Shyti , Wolfram Sang , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jean Delvare , Andy Shevchenko Subject: [PATCH v2 11/11] i2c: isch: Convert to kernel-doc Date: Mon, 16 Sep 2024 15:01:38 +0300 Message-ID: <20240916120237.1385982-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> References: <20240916120237.1385982-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert existing descriptions to kernel-doc format and unify the rest of the comments to follow the modern style. Signed-off-by: Andy Shevchenko --- drivers/i2c/busses/i2c-isch.c | 48 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c index b2857e8e1c58..2b3b65ef2900 100644 --- a/drivers/i2c/busses/i2c-isch.c +++ b/drivers/i2c/busses/i2c-isch.c @@ -1,13 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only /* - i2c-isch.c - Linux kernel driver for Intel SCH chipset SMBus - - Based on i2c-piix4.c - Copyright (c) 1998 - 2002 Frodo Looijaard and - Philip Edelbrock - - Intel SCH support - Copyright (c) 2007 - 2008 Jacob Jun Pan - -*/ + * Linux kernel driver for Intel SCH chipset SMBus + * - Based on i2c-piix4.c + * Copyright (c) 1998 - 2002 Frodo Looijaard and + * Philip Edelbrock + * - Intel SCH support + * Copyright (c) 2007 - 2008 Jacob Jun Pan + */ /* Supports: Intel SCH chipsets (AF82US15W, AF82US15L, AF82UL11L) */ @@ -72,10 +71,14 @@ static inline void sch_io_wr16(struct sch_i2c *priv, unsigned int offset, u16 va iowrite16(value, priv->smba + offset); } -/* - * Start the i2c transaction -- the i2c_access will prepare the transaction - * and this function will execute it. - * return 0 for success and others for failure. +/** + * sch_transaction - Start the i2c transaction + * @adap: the i2c adapter pointer + * + * The sch_access() will prepare the transaction and + * this function will execute it. + * + * Return: 0 for success and others for failure. */ static int sch_transaction(struct i2c_adapter *adap) { @@ -105,7 +108,7 @@ static int sch_transaction(struct i2c_adapter *adap) } } - /* start the transaction by setting bit 4 */ + /* Start the transaction by setting bit 4 */ temp = sch_io_rd8(priv, SMBHSTCNT); temp |= 0x10; sch_io_wr8(priv, SMBHSTCNT, temp); @@ -141,12 +144,17 @@ static int sch_transaction(struct i2c_adapter *adap) return rc; } -/* - * This is the main access entry for i2c-sch access - * adap is i2c_adapter pointer, addr is the i2c device bus address, read_write - * (0 for read and 1 for write), size is i2c transaction type and data is the - * union of transaction for data to be transferred or data read from bus. - * return 0 for success and others for failure. +/** + * sch_access - the main access entry for i2c-sch access + * @adap: the i2c adapter pointer + * @addr: the i2c device bus address + * @flags: I2C_CLIENT_* flags (usually zero or I2C_CLIENT_PEC) + * @read_write: 0 for read and 1 for write + * @command: Byte interpreted by slave, for protocols which use such bytes + * @size: the i2c transaction type + * @data: the union of transaction for data to be transferred or data read from bus + * + * Return: 0 for success and others for failure. */ static s32 sch_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, @@ -281,7 +289,7 @@ static int smbus_sch_probe(struct platform_device *pdev) if (!priv->smba) return dev_err_probe(dev, -EBUSY, "SMBus region %pR already in use!\n", res); - /* set up the sysfs linkage to our parent device */ + /* Set up the sysfs linkage to our parent device */ priv->adapter.dev.parent = dev; priv->adapter.owner = THIS_MODULE, priv->adapter.class = I2C_CLASS_HWMON,