From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HaVvNJGB" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D 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 =3D 0; int retries =3D 0; =20 - dev_dbg(&sch_adapter.dev, "Transaction (pre): CNT=3D%02x, CMD=3D%02x, " - "ADD=3D%02x, DAT0=3D%02x, DAT1=3D%02x\n", inb(SMBHSTCNT), + dev_dbg(&adap->dev, + "Transaction (pre): CNT=3D%02x, CMD=3D%02x, ADD=3D%02x, DAT0=3D%02x, DAT= 1=3D%02x\n", + inb(SMBHSTCNT), inb(SMBHSTCMD), inb(SMBHSTADD), inb(SMBHSTDAT0), inb(SMBHSTDAT1)); =20 @@ -70,19 +71,14 @@ static int sch_transaction(void) temp =3D 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 =3D 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) =20 /* 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 =3D -ETIMEDOUT; } else if (temp & 0x04) { result =3D -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 =3D -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 =3D 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 =3D -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=3D%02x, CMD=3D%02x, " - "ADD=3D%02x, DAT0=3D%02x, DAT1=3D%02x\n", inb(SMBHSTCNT), + dev_dbg(&adap->dev, "Transaction (post): CNT=3D%02x, CMD=3D%02x, ADD=3D%0= 2x, DAT0=3D%02x, DAT1=3D%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 add= r, /* Make sure the SMBus host is not busy */ temp =3D 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 =3D inw(SMBHSTCLK); @@ -154,13 +149,11 @@ static s32 sch_access(struct i2c_adapter *adap, u16 a= ddr, * 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); } =20 - 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":"WR= ITE"); 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 a= ddr, 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); =20 - rc =3D sch_transaction(); + rc =3D sch_transaction(adap); if (rc) /* Error in transaction */ return rc; =20 --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Q1Xqre9Q" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 /* SCH SMBus address offsets */ #define SMBHSTCNT (0 + sch_smba) @@ -153,7 +154,7 @@ static s32 sch_access(struct i2c_adapter *adap, u16 add= r, outw(backbone_speed / (4 * 100), SMBHSTCLK); } =20 - dev_dbg(&adap->dev, "access size: %d %s\n", size, (read_write)?"READ":"WR= ITE"); + dev_dbg(&adap->dev, "access size: %d %s\n", size, str_read_write(read_wri= te)); switch (size) { case I2C_SMBUS_QUICK: outb((addr << 1) | read_write, SMBHSTADD); --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="D60d0ALZ" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 /* 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 =20 /* Other settings */ #define MAX_RETRIES 5000 @@ -45,12 +46,33 @@ #define SCH_WORD_DATA 0x03 #define SCH_BLOCK_DATA 0x05 =20 -static unsigned short sch_smba; static struct i2c_adapter sch_adapter; +static void __iomem *sch_smba; + static int backbone_speed =3D 33000; /* backbone speed in kHz */ module_param(backbone_speed, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(backbone_speed, "Backbone speed in kHz, (default =3D 3300= 0)"); =20 +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, u1= 6 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) =20 dev_dbg(&adap->dev, "Transaction (pre): CNT=3D%02x, CMD=3D%02x, ADD=3D%02x, DAT0=3D%02x, DAT= 1=3D%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)); =20 /* Make sure the SMBus host is ready to start transmitting */ - temp =3D inb(SMBHSTSTS) & 0x0f; + temp =3D 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 =3D inb(SMBHSTSTS) & 0x0f; + sch_io_wr8(sch_smba, SMBHSTSTS, temp); + temp =3D 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) } =20 /* start the transaction by setting bit 4 */ - outb(inb(SMBHSTCNT) | 0x10, SMBHSTCNT); + temp =3D sch_io_rd8(sch_smba, SMBHSTCNT); + temp |=3D 0x10; + sch_io_wr8(sch_smba, SMBHSTCNT, temp); =20 do { usleep_range(100, 200); - temp =3D inb(SMBHSTSTS) & 0x0f; + temp =3D sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); =20 /* 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 =3D inb(SMBHSTSTS) & 0x07; + sch_io_wr8(sch_smba, SMBHSTSTS, temp); + temp =3D 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=3D%02x, CMD=3D%02x, ADD=3D%0= 2x, DAT0=3D%02x, DAT1=3D%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; } =20 @@ -137,12 +161,12 @@ static s32 sch_access(struct i2c_adapter *adap, u16 a= ddr, int i, len, temp, rc; =20 /* Make sure the SMBus host is not busy */ - temp =3D inb(SMBHSTSTS) & 0x0f; + temp =3D sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; if (temp & 0x08) { dev_dbg(&adap->dev, "SMBus busy (%02x)\n", temp); return -EAGAIN; } - temp =3D inw(SMBHSTCLK); + temp =3D 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 a= ddr, * 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)); } =20 dev_dbg(&adap->dev, "access size: %d %s\n", size, str_read_write(read_wri= te)); switch (size) { case I2C_SMBUS_QUICK: - outb((addr << 1) | read_write, SMBHSTADD); + sch_io_wr8(sch_smba, SMBHSTADD, (addr << 1) | read_write); size =3D 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 =3D=3D I2C_SMBUS_WRITE) - outb(command, SMBHSTCMD); + sch_io_wr8(sch_smba, SMBHSTCMD, command); size =3D 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 =3D=3D I2C_SMBUS_WRITE) - outb(data->byte, SMBHSTDAT0); + sch_io_wr8(sch_smba, SMBHSTDAT0, data->byte); size =3D 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 =3D=3D 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 =3D 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 =3D=3D I2C_SMBUS_WRITE) { len =3D data->block[0]; if (len =3D=3D 0 || len > I2C_SMBUS_BLOCK_MAX) return -EINVAL; - outb(len, SMBHSTDAT0); + sch_io_wr8(sch_smba, SMBHSTDAT0, len); for (i =3D 1; i <=3D len; i++) - outb(data->block[i], SMBBLKDAT+i-1); + sch_io_wr8(sch_smba, SMBBLKDAT + i - 1, data->block[i]); } size =3D SCH_BLOCK_DATA; break; @@ -200,7 +224,10 @@ static s32 sch_access(struct i2c_adapter *adap, u16 ad= dr, return -EOPNOTSUPP; } dev_dbg(&adap->dev, "write size %d to 0x%04x\n", size, SMBHSTCNT); - outb((inb(SMBHSTCNT) & 0xb0) | (size & 0x7), SMBHSTCNT); + + temp =3D sch_io_rd8(sch_smba, SMBHSTCNT); + temp =3D (temp & 0xb0) | (size & 0x7); + sch_io_wr8(sch_smba, SMBHSTCNT, temp); =20 rc =3D sch_transaction(adap); if (rc) /* Error in transaction */ @@ -212,17 +239,18 @@ static s32 sch_access(struct i2c_adapter *adap, u16 a= ddr, switch (size) { case SCH_BYTE: case SCH_BYTE_DATA: - data->byte =3D inb(SMBHSTDAT0); + data->byte =3D sch_io_rd8(sch_smba, SMBHSTDAT0); break; case SCH_WORD_DATA: - data->word =3D inb(SMBHSTDAT0) + (inb(SMBHSTDAT1) << 8); + data->word =3D (sch_io_rd8(sch_smba, SMBHSTDAT0) << 0) + + (sch_io_rd8(sch_smba, SMBHSTDAT1) << 8); break; case SCH_BLOCK_DATA: - data->block[0] =3D inb(SMBHSTDAT0); + data->block[0] =3D sch_io_rd8(sch_smba, SMBHSTDAT0); if (data->block[0] =3D=3D 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX) return -EPROTO; for (i =3D 1; i <=3D data->block[0]; i++) - data->block[i] =3D inb(SMBBLKDAT+i-1); + data->block[i] =3D sch_io_rd8(sch_smba, SMBBLKDAT + i - 1); break; } return 0; @@ -255,26 +283,21 @@ static int smbus_sch_probe(struct platform_device *de= v) if (!res) return -EBUSY; =20 - 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 =3D 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; } =20 - sch_smba =3D res->start; - - dev_dbg(&dev->dev, "SMBA =3D 0x%X\n", sch_smba); - /* set up the sysfs linkage to our parent device */ sch_adapter.dev.parent =3D &dev->dev; =20 snprintf(sch_adapter.name, sizeof(sch_adapter.name), - "SMBus SCH adapter at %04x", sch_smba); + "SMBus SCH adapter at %04x", (unsigned short)res->start); =20 retval =3D i2c_add_adapter(&sch_adapter); if (retval) - sch_smba =3D 0; + sch_smba =3D NULL; =20 return retval; } @@ -283,7 +306,7 @@ static void smbus_sch_remove(struct platform_device *pd= ev) { if (sch_smba) { i2c_del_adapter(&sch_adapter); - sch_smba =3D 0; + sch_smba =3D NULL; } } =20 --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="PchLsjXn" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 @@ =20 */ =20 -/* - 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) */ =20 #include #include #include +#include #include +#include #include #include #include @@ -46,31 +44,33 @@ #define SCH_WORD_DATA 0x03 #define SCH_BLOCK_DATA 0x05 =20 -static struct i2c_adapter sch_adapter; -static void __iomem *sch_smba; +struct sch_i2c { + struct i2c_adapter adapter; + void __iomem *smba; +}; =20 static int backbone_speed =3D 33000; /* backbone speed in kHz */ module_param(backbone_speed, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(backbone_speed, "Backbone speed in kHz, (default =3D 3300= 0)"); =20 -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); } =20 -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, u= 8 value) { - iowrite8(value, smba + offset); + iowrite8(value, priv->smba + offset); } =20 -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); } =20 -static inline void sch_io_wr16(void __iomem *smba, unsigned int offset, u1= 6 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); } =20 /* @@ -80,26 +80,27 @@ static inline void sch_io_wr16(void __iomem *smba, unsi= gned int offset, u16 valu */ static int sch_transaction(struct i2c_adapter *adap) { + struct sch_i2c *priv =3D container_of(adap, struct sch_i2c, adapter); int temp; int result =3D 0; int retries =3D 0; =20 dev_dbg(&adap->dev, "Transaction (pre): CNT=3D%02x, CMD=3D%02x, ADD=3D%02x, DAT0=3D%02x, DAT= 1=3D%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)); =20 /* Make sure the SMBus host is ready to start transmitting */ - temp =3D sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; + temp =3D 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 =3D sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; + sch_io_wr8(priv, SMBHSTSTS, temp); + temp =3D 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) } =20 /* start the transaction by setting bit 4 */ - temp =3D sch_io_rd8(sch_smba, SMBHSTCNT); + temp =3D sch_io_rd8(priv, SMBHSTCNT); temp |=3D 0x10; - sch_io_wr8(sch_smba, SMBHSTCNT, temp); + sch_io_wr8(priv, SMBHSTCNT, temp); =20 do { usleep_range(100, 200); - temp =3D sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; + temp =3D sch_io_rd8(priv, SMBHSTSTS) & 0x0f; } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); =20 /* 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 =3D sch_io_rd8(sch_smba, SMBHSTSTS) & 0x07; + sch_io_wr8(priv, SMBHSTSTS, temp); + temp =3D 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=3D%02x, CMD=3D%02x, ADD=3D%0= 2x, DAT0=3D%02x, DAT1=3D%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; } =20 @@ -158,15 +159,16 @@ static s32 sch_access(struct i2c_adapter *adap, u16 a= ddr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data) { + struct sch_i2c *priv =3D container_of(adap, struct sch_i2c, adapter); int i, len, temp, rc; =20 /* Make sure the SMBus host is not busy */ - temp =3D sch_io_rd8(sch_smba, SMBHSTSTS) & 0x0f; + temp =3D sch_io_rd8(priv, SMBHSTSTS) & 0x0f; if (temp & 0x08) { dev_dbg(&adap->dev, "SMBus busy (%02x)\n", temp); return -EAGAIN; } - temp =3D sch_io_rd16(sch_smba, SMBHSTCLK); + temp =3D 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 a= ddr, * 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)); } =20 dev_dbg(&adap->dev, "access size: %d %s\n", size, str_read_write(read_wri= te)); 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 =3D 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 =3D=3D I2C_SMBUS_WRITE) - sch_io_wr8(sch_smba, SMBHSTCMD, command); + sch_io_wr8(priv, SMBHSTCMD, command); size =3D 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 =3D=3D I2C_SMBUS_WRITE) - sch_io_wr8(sch_smba, SMBHSTDAT0, data->byte); + sch_io_wr8(priv, SMBHSTDAT0, data->byte); size =3D 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 =3D=3D 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 =3D 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 =3D=3D I2C_SMBUS_WRITE) { len =3D data->block[0]; if (len =3D=3D 0 || len > I2C_SMBUS_BLOCK_MAX) return -EINVAL; - sch_io_wr8(sch_smba, SMBHSTDAT0, len); + sch_io_wr8(priv, SMBHSTDAT0, len); for (i =3D 1; i <=3D len; i++) - sch_io_wr8(sch_smba, SMBBLKDAT + i - 1, data->block[i]); + sch_io_wr8(priv, SMBBLKDAT + i - 1, data->block[i]); } size =3D SCH_BLOCK_DATA; break; @@ -225,9 +227,9 @@ static s32 sch_access(struct i2c_adapter *adap, u16 add= r, } dev_dbg(&adap->dev, "write size %d to 0x%04x\n", size, SMBHSTCNT); =20 - temp =3D sch_io_rd8(sch_smba, SMBHSTCNT); + temp =3D sch_io_rd8(priv, SMBHSTCNT); temp =3D (temp & 0xb0) | (size & 0x7); - sch_io_wr8(sch_smba, SMBHSTCNT, temp); + sch_io_wr8(priv, SMBHSTCNT, temp); =20 rc =3D sch_transaction(adap); if (rc) /* Error in transaction */ @@ -239,18 +241,18 @@ static s32 sch_access(struct i2c_adapter *adap, u16 a= ddr, switch (size) { case SCH_BYTE: case SCH_BYTE_DATA: - data->byte =3D sch_io_rd8(sch_smba, SMBHSTDAT0); + data->byte =3D sch_io_rd8(priv, SMBHSTDAT0); break; case SCH_WORD_DATA: - data->word =3D (sch_io_rd8(sch_smba, SMBHSTDAT0) << 0) + - (sch_io_rd8(sch_smba, SMBHSTDAT1) << 8); + data->word =3D (sch_io_rd8(priv, SMBHSTDAT0) << 0) + + (sch_io_rd8(priv, SMBHSTDAT1) << 8); break; case SCH_BLOCK_DATA: - data->block[0] =3D sch_io_rd8(sch_smba, SMBHSTDAT0); + data->block[0] =3D sch_io_rd8(priv, SMBHSTDAT0); if (data->block[0] =3D=3D 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX) return -EPROTO; for (i =3D 1; i <=3D data->block[0]; i++) - data->block[i] =3D sch_io_rd8(sch_smba, SMBBLKDAT + i - 1); + data->block[i] =3D sch_io_rd8(priv, SMBBLKDAT + i - 1); break; } return 0; @@ -268,46 +270,49 @@ static const struct i2c_algorithm smbus_algorithm =3D= { .functionality =3D sch_func, }; =20 -static struct i2c_adapter sch_adapter =3D { - .owner =3D THIS_MODULE, - .class =3D I2C_CLASS_HWMON, - .algo =3D &smbus_algorithm, -}; - static int smbus_sch_probe(struct platform_device *dev) { + struct sch_i2c *priv; struct resource *res; int retval; =20 + priv =3D devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + res =3D platform_get_resource(dev, IORESOURCE_IO, 0); if (!res) return -EBUSY; =20 - sch_smba =3D devm_ioport_map(&dev->dev, res->start, resource_size(res)); - if (!sch_smba) { + priv->smba =3D 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; } =20 /* set up the sysfs linkage to our parent device */ - sch_adapter.dev.parent =3D &dev->dev; + priv->adapter.dev.parent =3D &dev->dev; + priv->adapter.owner =3D THIS_MODULE, + priv->adapter.class =3D I2C_CLASS_HWMON, + priv->adapter.algo =3D &smbus_algorithm, =20 - 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); =20 - retval =3D i2c_add_adapter(&sch_adapter); + retval =3D i2c_add_adapter(&priv->adapter); if (retval) - sch_smba =3D NULL; + return retval; =20 - return retval; + platform_set_drvdata(dev, priv); + + return 0; } =20 static void smbus_sch_remove(struct platform_device *pdev) { - if (sch_smba) { - i2c_del_adapter(&sch_adapter); - sch_smba =3D NULL; - } + struct sch_i2c *priv =3D platform_get_drvdata(pdev); + + i2c_del_adapter(&priv->adapter); } =20 static struct platform_driver smbus_sch_driver =3D { --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="S0J/rmvg" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; =20 priv =3D 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); =20 - retval =3D 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 =3D platform_get_drvdata(pdev); - - i2c_del_adapter(&priv->adapter); + return devm_i2c_add_adapter(&dev->dev, &priv->adapter); } =20 static struct platform_driver smbus_sch_driver =3D { @@ -320,7 +306,6 @@ static struct platform_driver smbus_sch_driver =3D { .name =3D "isch_smbus", }, .probe =3D smbus_sch_probe, - .remove_new =3D smbus_sch_remove, }; =20 module_platform_driver(smbus_sch_driver); --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UmWCXMuB" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D= { .functionality =3D sch_func, }; =20 -static int smbus_sch_probe(struct platform_device *dev) +static int smbus_sch_probe(struct platform_device *pdev) { + struct device *dev =3D &pdev->dev; struct sch_i2c *priv; struct resource *res; =20 - priv =3D devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL); + priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; =20 - res =3D platform_get_resource(dev, IORESOURCE_IO, 0); + res =3D platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res) return -EBUSY; =20 - priv->smba =3D 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 =3D 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); =20 /* set up the sysfs linkage to our parent device */ - priv->adapter.dev.parent =3D &dev->dev; + priv->adapter.dev.parent =3D dev; priv->adapter.owner =3D THIS_MODULE, priv->adapter.class =3D I2C_CLASS_HWMON, priv->adapter.algo =3D &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); =20 - return devm_i2c_add_adapter(&dev->dev, &priv->adapter); + return devm_i2c_add_adapter(dev, &priv->adapter); } =20 static struct platform_driver smbus_sch_driver =3D { --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KDWAeeJL" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 -/* 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 =3D container_of(adap, struct sch_i2c, adapter); int temp; int result =3D 0; - int retries =3D 0; =20 dev_dbg(&adap->dev, "Transaction (pre): CNT=3D%02x, CMD=3D%02x, ADD=3D%02x, DAT0=3D%02x, DAT= 1=3D%02x\n", @@ -112,15 +108,11 @@ static int sch_transaction(struct i2c_adapter *adap) temp |=3D 0x10; sch_io_wr8(priv, SMBHSTCNT, temp); =20 - do { - usleep_range(100, 200); - temp =3D sch_io_rd8(priv, SMBHSTSTS) & 0x0f; - } while ((temp & 0x08) && (retries++ < MAX_RETRIES)); - + result =3D read_poll_timeout(sch_io_rd8, temp, !(temp & 0x08), 200, 50000= 0, 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 =3D -ETIMEDOUT; } else if (temp & 0x04) { result =3D -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 =3D sch_io_rd8(priv, SMBHSTSTS) & 0x07; if (temp & 0x06) { /* Completion clear failed */ --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Sd6yRg1V" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D container_of(adap, struct sch_i2c, adapter); int temp; - int result =3D 0; + int rc; =20 dev_dbg(&adap->dev, "Transaction (pre): CNT=3D%02x, CMD=3D%02x, ADD=3D%02x, DAT0=3D%02x, DAT= 1=3D%02x\n", @@ -108,17 +108,16 @@ static int sch_transaction(struct i2c_adapter *adap) temp |=3D 0x10; sch_io_wr8(priv, SMBHSTCNT, temp); =20 - result =3D read_poll_timeout(sch_io_rd8, temp, !(temp & 0x08), 200, 50000= 0, true, - priv, SMBHSTSTS); + rc =3D read_poll_timeout(sch_io_rd8, temp, !(temp & 0x08), 200, 500000, t= rue, 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 =3D -EIO; + rc =3D -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 =3D -EIO; + rc =3D -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 =3D -ENXIO; + rc =3D -ENXIO; dev_dbg(&adap->dev, "No such address.\n"); } dev_dbg(&adap->dev, "Transaction (post): CNT=3D%02x, CMD=3D%02x, ADD=3D%0= 2x, DAT0=3D%02x, DAT1=3D%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; } =20 /* --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UVytRDYQ" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 @@ =20 /* Supports: Intel SCH chipsets (AF82US15W, AF82US15L, AF82UL11L) */ =20 -#include -#include -#include #include #include #include +#include +#include #include #include #include +#include +#include +#include #include #include #include --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UCt4DuEM" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 { }; =20 static int backbone_speed =3D 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 =3D 3300= 0)"); =20 static inline u8 sch_io_rd8(struct sch_i2c *priv, unsigned int offset) --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Fri Nov 29 19:41:40 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="LoUisgIY" 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 + */ =20 /* Supports: Intel SCH chipsets (AF82US15W, AF82US15L, AF82UL11L) */ =20 @@ -72,10 +71,14 @@ static inline void sch_io_wr16(struct sch_i2c *priv, un= signed int offset, u16 va iowrite16(value, priv->smba + offset); } =20 -/* - * 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) } } =20 - /* start the transaction by setting bit 4 */ + /* Start the transaction by setting bit 4 */ temp =3D sch_io_rd8(priv, SMBHSTCNT); temp |=3D 0x10; sch_io_wr8(priv, SMBHSTCNT, temp); @@ -141,12 +144,17 @@ static int sch_transaction(struct i2c_adapter *adap) return rc; } =20 -/* - * This is the main access entry for i2c-sch access - * adap is i2c_adapter pointer, addr is the i2c device bus address, read_w= rite - * (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); =20 - /* set up the sysfs linkage to our parent device */ + /* Set up the sysfs linkage to our parent device */ priv->adapter.dev.parent =3D dev; priv->adapter.owner =3D THIS_MODULE, priv->adapter.class =3D I2C_CLASS_HWMON, --=20 2.43.0.rc1.1336.g36b5255a03ac