From patchwork Fri Feb 2 07:01:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 769677 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7D9718AEE for ; Fri, 2 Feb 2024 07:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857303; cv=none; b=HWznp3EXm4XYNHqmfqQHVldzLcHc2W9jy5rx3pHQTGNR9ArMwP6sgd8Q/2JUTUAU6DXA/PZY/oZ/1YX8rqvqTkQDJdvD2eDCSNUxleu4rywQpLpyjo5D3+YKxGHTczIksBk1rXM6EbavbRVH7zWFj7GuFzgDV/4HA5GyvxOTyqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857303; c=relaxed/simple; bh=owVQLKr6rpnxB3Phw+LfqRTsk/Ggy2NJGYylyhXqk3k=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=cznzjiHQfVy8Ror/8JQivDWeZzd82OaSS/th1W1Fnwt4HNdAgVvhIJlXZANCbN9HNRoDkc6vOtx5E4pbCqroWROc1oaxVD6QGPtyq4wKWmrjHAvASOg4W2yGmZeRDiC+iYDtUvx5fMfctpETwe7kC1KqyJOn20QJ4a0MvSv72Dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HgQF1an7; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HgQF1an7" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-55f15762840so2128339a12.0 for ; Thu, 01 Feb 2024 23:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706857300; x=1707462100; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=0HjmSHBbMzkUICJtwESwKX7/y9Aw2qA4XC0RG+MyGE4=; b=HgQF1an7NOZIPjHdJVgrjrHcmj4dZnyxRCAFMCDplWDOV1PnQhpio9uX90HG1UGkG7 3V2pzaLXddsNxFG1vuKH/f+rE8ATyOljRQ5Uirx7zd2GdSuKv7YxC8z/jtblBzpgvVuj Nx/rQ5pl6veu/z/ri90j6w9mZqQ/Il6N6W6TQ7SEplc3fEh92xZ16oighKFrnGwGL869 kc65l7oZHTjrd4+26bfFmXeytt0IjBGeteEef/u9Nen4A/4kwaQlhJ0VVtUqdyQhsTcs kDywgu9pgIsa8CFVCfXoaBhzLvyPlD4m5v7faVL/tCn26uCAm7+6K9KE1+WU2jb/hqyA Wa9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706857300; x=1707462100; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0HjmSHBbMzkUICJtwESwKX7/y9Aw2qA4XC0RG+MyGE4=; b=jFYA7pKqsYlylMJ4+6YLDXDvoGqIpkjAZwcuNY120tH0SjQZtP56reLwNiFI+UsXY+ xSWAnXCYa2whM+t8bJxF1XJf065j4GDkIduFddI5MtR12Pnemih8twUKJ/FQLV+OcO52 uZ2onn8qTSRpfeaacF8a+ol7ggOvRqpANs/TtByhcc8tYQ3cWMfT9t9GMF5pnIkMe9Wj 3SBhZu8+Mo3OfEHt7E2foBsU/sG5gBLrgoJ1EXixmrYtO24zalhUhtSxYI8Gv3x9mV8Q yw6458lPofy+QuHEsRCTxJp7a0zOBRVd78AK3pyNNqrbiDI9J7eDAYCsK2Ze5kA/zvAu u2gg== X-Gm-Message-State: AOJu0YwesgOUd0Go+LJ7lnJNYY0SeUku4FES5V5WA75AUGbVKWv3WVD/ 9wOtpAYKuFzyuqdwF41aqKiwRqnO12hWHryeI2+AxyI8raph85rGJgFdNq2F X-Google-Smtp-Source: AGHT+IEZLEjTBVJtEy4LJ0UkzAMZmIgehOE1sZPx4F8glLhU881knXD73IaVBJpLSJvBtZbIVGKMZg== X-Received: by 2002:a17:906:e0d7:b0:a36:1240:71d with SMTP id gl23-20020a170906e0d700b00a361240071dmr4851282ejb.53.1706857299586; Thu, 01 Feb 2024 23:01:39 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWNQWEuIyLrnF4cTZVlJViV3CfkpMfeFDYoCyJkjYJun6fzDR6griguflHoqeV04KJbcSkTGP1N/EPpGTL5BQ9hx/wVRf6lhB0WOg6ztIYiJmq5049ulDliy+WrKW9ihajbNn31mM2yPg== Received: from ?IPV6:2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea? (dynamic-2a01-0c22-7392-d000-5c1a-bcfc-a8a4-5bea.c22.pool.telefonica.de. [2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea]) by smtp.googlemail.com with ESMTPSA id c3-20020a170906340300b00a35a659cab5sm563728ejb.179.2024.02.01.23.01.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Feb 2024 23:01:39 -0800 (PST) Message-ID: <35e178dc-120f-4035-bbb2-85417d2f2c4d@gmail.com> Date: Fri, 2 Feb 2024 08:01:41 +0100 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 1/5] i2c: i801: Define FEATURES_ICH5 as an extension of FEATURES_ICH4 Content-Language: en-US From: Heiner Kallweit To: Jean Delvare , Andi Shyti Cc: "linux-i2c@vger.kernel.org" , Andy Shevchenko References: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> Autocrypt: addr=hkallweit1@gmail.com; keydata= xsFNBF/0ZFUBEAC0eZyktSE7ZNO1SFXL6cQ4i4g6Ah3mOUIXSB4pCY5kQ6OLKHh0FlOD5/5/ sY7IoIouzOjyFdFPnz4Bl3927ClT567hUJJ+SNaFEiJ9vadI6vZm2gcY4ExdIevYHWe1msJF MVE4yNwdS+UsPeCF/6CQQTzHc+n7DomE7fjJD5J1hOJjqz2XWe71fTvYXzxCFLwXXbBiqDC9 dNqOe5odPsa4TsWZ09T33g5n2nzTJs4Zw8fCy8rLqix/raVsqr8fw5qM66MVtdmEljFaJ9N8 /W56qGCp+H8Igk/F7CjlbWXiOlKHA25mPTmbVp7VlFsvsmMokr/imQr+0nXtmvYVaKEUwY2g 86IU6RAOuA8E0J5bD/BeyZdMyVEtX1kT404UJZekFytJZrDZetwxM/cAH+1fMx4z751WJmxQ J7mIXSPuDfeJhRDt9sGM6aRVfXbZt+wBogxyXepmnlv9K4A13z9DVLdKLrYUiu9/5QEl6fgI kPaXlAZmJsQfoKbmPqCHVRYj1lpQtDM/2/BO6gHASflWUHzwmBVZbS/XRs64uJO8CB3+V3fa cIivllReueGCMsHh6/8wgPAyopXOWOxbLsZ291fmZqIR0L5Y6b2HvdFN1Xhc+YrQ8TKK+Z4R mJRDh0wNQ8Gm89g92/YkHji4jIWlp2fwzCcx5+lZCQ1XdqAiHQARAQABzSZIZWluZXIgS2Fs bHdlaXQgPGhrYWxsd2VpdDFAZ21haWwuY29tPsLBjg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L8YUQFZYm+JUIgfRmSpMFq8JP4VH43GXpB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> This change simplifies the code a little and makes clearer that the ICH5 feature set is an extension of the ICH4 feature set. Signed-off-by: Heiner Kallweit Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-i801.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index b9b850b69..44ae6326d 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -969,11 +969,10 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = i801_func, }; -#define FEATURES_ICH5 (FEATURE_BLOCK_PROC | FEATURE_I2C_BLOCK_READ | \ - FEATURE_IRQ | FEATURE_SMBUS_PEC | \ - FEATURE_BLOCK_BUFFER | FEATURE_HOST_NOTIFY) #define FEATURES_ICH4 (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER | \ FEATURE_HOST_NOTIFY) +#define FEATURES_ICH5 (FEATURES_ICH4 | FEATURE_BLOCK_PROC | \ + FEATURE_I2C_BLOCK_READ | FEATURE_IRQ) static const struct pci_device_id i801_ids[] = { { PCI_DEVICE_DATA(INTEL, 82801AA_3, 0) }, From patchwork Fri Feb 2 07:02:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 769345 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 882EE18E12 for ; Fri, 2 Feb 2024 07:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857341; cv=none; b=QhfPAtsQaovR4nQwRbY0j4tj6hKws7h9BNxAypVSPUVFv8zRai4/CyIIXSY9yGTO+a5vMM9BshWYs5PH/wL8UJkQgLhWh478Cv3BF7gtzNjaLeSyfaKunfDyvoOhVLWgYKxf3jNsYVgaGmKJgzkNaaxehok9eMGuO+hO90E1uZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857341; c=relaxed/simple; bh=fve07InBj9wYw56bY6g1yshIjEjacjDwh16fxJqt19M=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=FnQfGqIanbeAQPBLVL8tm0G2bJS0rEacl27NZ/f8dcCslMnzdD9fXlYghtxMYsF+zRWKxrxXZqBMnfwLIiQSu4CCIi5BcAsvXAM+2OE3jRHyj5MFOsDBK4jZ5Fo9uC4EYOxK704gwg+KdW7poac2ikEiYv4SlN9gaLoJAVg+J0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fRleRLL4; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fRleRLL4" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a364b5c5c19so290576866b.1 for ; Thu, 01 Feb 2024 23:02:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706857338; x=1707462138; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=cnOacyhJglkzROB1Zm6vEH9B1X6rxEKHJsPgyQcXjH8=; b=fRleRLL4dIVni2+1yD5RQvQ2n6EdgebK6aFdaEZa+QhqGZjW+8r3bU/Mezs83B0ewL 1/zoIQbKckY2ROluO/esMf5OISx++vRzUwtdYPq9kID9bZvmFv2/bq1a4OTQUSiynHD2 xD75gncVykvYq9+DyUXsEgPyfBv9OGuREjV4nGo7aTC2xaJLj6HVdDV51eAaED2ssfhH vipAtVCt/SZf+EN4qrZnH6vb1o6ommtVHu2qWRT9ZAL7JQHc1XPETL98LbvlR5jHQM9r oV/MiFk/cpDmFANld4jbwYbzvw0oNBoze/Dqph3VlP5BDUFORFEes3SyiVIgVkvTtnR0 MYUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706857338; x=1707462138; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cnOacyhJglkzROB1Zm6vEH9B1X6rxEKHJsPgyQcXjH8=; b=u8kNjpqcl8a0djJ6WZr6FJ4sQTLm4ypBFcX7y+oe14ciLryQWQirC/Cde7cGT9eqae /AzPfVV76VbUF8K7Fa99GZor8sAwwgDgVUUPajSyGEk5uSThpmLubMkXsHIRKIyfiPW3 HdxtWi5OaLj1swurM2CKiajqQUFShloCEsiXkFUrpwJMZtBZCOP2i+YMNy7Bs0BnXAVy Lz9HAe7LAByqQWpzYKRbnVFAnfUD9KSGyI+D+OQa19t4/9C3/5PS4luJo06GBhawKLqM ZDPr1e4IschTFKj2fZI4HQFRIBkFC4iOn0NExvES36ej/qzjqqYJwxhwNuG57my9Mw/R Ckzw== X-Gm-Message-State: AOJu0Ywh5lZ6hiWt/xPU5LpMnIGcAlAqXc9kos4wqFF/X13VAJoUR3v7 QansKor0ZPlmQSoquAsjlUPm2O9FYCtBcEbFufnBCCJdr3FnvM/zMtcj8obK X-Google-Smtp-Source: AGHT+IGkgilOMrh+kOrz0Xzsh+mCkYYuow4rCfb/pFA4oZKFOgP0vu0Tan3Los+eaiH63BEXoYIprg== X-Received: by 2002:a17:906:e0cd:b0:a35:3bed:6cb4 with SMTP id gl13-20020a170906e0cd00b00a353bed6cb4mr4864758ejb.66.1706857337576; Thu, 01 Feb 2024 23:02:17 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWNPtJCPkcJt1Wn3u8BzMqEhdynRfeD/eM8JNyw4QjuHOmVaE5jrthrSHva4+KKe4ULB8mRzTRULiTULJvgPoTRiPjf92hB/BteBTA7i4k7IGB5XJWD0l69r7KuKSXxymxRw/Z60AFT5A== Received: from ?IPV6:2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea? (dynamic-2a01-0c22-7392-d000-5c1a-bcfc-a8a4-5bea.c22.pool.telefonica.de. [2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea]) by smtp.googlemail.com with ESMTPSA id c3-20020a170906340300b00a35a659cab5sm563728ejb.179.2024.02.01.23.02.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Feb 2024 23:02:17 -0800 (PST) Message-ID: Date: Fri, 2 Feb 2024 08:02:19 +0100 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 2/5] i2c: i801: Add helper i801_check_and_clear_pec_error Content-Language: en-US From: Heiner Kallweit To: Jean Delvare , Andi Shyti Cc: "linux-i2c@vger.kernel.org" , Andy Shevchenko References: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> Autocrypt: addr=hkallweit1@gmail.com; keydata= xsFNBF/0ZFUBEAC0eZyktSE7ZNO1SFXL6cQ4i4g6Ah3mOUIXSB4pC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uDd2eyzGjrrFOsJEi8OK2d2j4FfF++ AzOMdW09JVqejQARAQABwsF2BBgBCAAgFiEEbF+pj/I7JePKMl6Fct6KD1TwOgwFAl/0ZFUC GwwACgkQct6KD1TwOgxUfg//eAoYc0Vm4NrxymfcY30UjHVD0LgSvU8kUmXxil3qhFPS7KA+ y7tgcKLHOkZkXMX5MLFcS9+SmrAjSBBV8omKoHNo+kfFx/dUAtz0lot8wNGmWb+NcHeKM1eb nwUMOEa1uDdfZeKef/U/2uHBceY7Gc6zPZPWgXghEyQMTH2UhLgeam8yglyO+A6RXCh+s6ak Wje7Vo1wGK4eYxp6pwMPJXLMsI0ii/2k3YPEJPv+yJf90MbYyQSbkTwZhrsokjQEaIfjrIk3 rQRjTve/J62WIO28IbY/mENuGgWehRlTAbhC4BLTZ5uYS0YMQCR7v9UGMWdNWXFyrOB6PjSu Trn9MsPoUc8qI72mVpxEXQDLlrd2ijEWm7Nrf52YMD7hL6rXXuis7R6zY8WnnBhW0uCfhajx q+KuARXC0sDLztcjaS3ayXonpoCPZep2Bd5xqE4Ln8/COCslP7E92W1uf1EcdXXIrx1acg21 H/0Z53okMykVs3a8tECPHIxnre2UxKdTbCEkjkR4V6JyplTS47oWMw3zyI7zkaadfzVFBxk2 lo/Tny+FX1Azea3Ce7oOnRUEZtWSsUidtIjmL8YUQFZYm+JUIgfRmSpMFq8JP4VH43GXpB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> Avoid code duplication and factor out checking and clearing PEC error bit to new helper i801_check_and_clear_pec_error(). Signed-off-by: Heiner Kallweit Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-i801.c | 38 ++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 44ae6326d..156bace92 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -328,11 +328,27 @@ MODULE_PARM_DESC(disable_features, "Disable selected driver features:\n" "\t\t 0x10 don't use interrupts\n" "\t\t 0x20 disable SMBus Host Notify "); +static int i801_check_and_clear_pec_error(struct i801_priv *priv) +{ + u8 status; + + if (!(priv->features & FEATURE_SMBUS_PEC)) + return 0; + + status = inb_p(SMBAUXSTS(priv)) & SMBAUXSTS_CRCE; + if (status) { + outb_p(status, SMBAUXSTS(priv)); + return -EBADMSG; + } + + return 0; +} + /* Make sure the SMBus host is ready to start transmitting. Return 0 if it is, -EBUSY if it is not. */ static int i801_check_pre(struct i801_priv *priv) { - int status; + int status, result; status = inb_p(SMBHSTSTS(priv)); if (status & SMBHSTSTS_HOST_BUSY) { @@ -353,13 +369,9 @@ static int i801_check_pre(struct i801_priv *priv) * the hardware was already in this state when the driver * started. */ - if (priv->features & FEATURE_SMBUS_PEC) { - status = inb_p(SMBAUXSTS(priv)) & SMBAUXSTS_CRCE; - if (status) { - pci_dbg(priv->pci_dev, "Clearing aux status flags (%02x)\n", status); - outb_p(status, SMBAUXSTS(priv)); - } - } + result = i801_check_and_clear_pec_error(priv); + if (result) + pci_dbg(priv->pci_dev, "Clearing aux status flag CRCE\n"); return 0; } @@ -408,14 +420,12 @@ static int i801_check_post(struct i801_priv *priv, int status) * bit is harmless as long as it's cleared before * the next operation. */ - if ((priv->features & FEATURE_SMBUS_PEC) && - (inb_p(SMBAUXSTS(priv)) & SMBAUXSTS_CRCE)) { - outb_p(SMBAUXSTS_CRCE, SMBAUXSTS(priv)); - result = -EBADMSG; - dev_dbg(&priv->pci_dev->dev, "PEC error\n"); + result = i801_check_and_clear_pec_error(priv); + if (result) { + pci_dbg(priv->pci_dev, "PEC error\n"); } else { result = -ENXIO; - dev_dbg(&priv->pci_dev->dev, "No response\n"); + pci_dbg(priv->pci_dev, "No response\n"); } } if (status & SMBHSTSTS_BUS_ERR) { From patchwork Fri Feb 2 07:02:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 769676 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB11517567 for ; Fri, 2 Feb 2024 07:02:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857377; cv=none; b=a8XNsBusSmX3vXUmMovwLjD44qzj7UIAUxH8zLr24gMB/JkYQrkfePpTMLxmmXgFOzM0foLIc/MPz83VEujw5EqXEkhwCp0pqywGRprHa/cZRNfZXgEly89kgNwd/0Wm+WEnVO7xFiJTMPClQyMSLJ1zwPYKaa6SCCFqRTNOXT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857377; c=relaxed/simple; bh=UgWeAAVf9siBe++4hNWMaqXJoulggWwd4XWfymnlkgQ=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=O3zmyCvVoLDM9beJqSky2PF/bIumhN6SI/okqBohlzLl64fCm68PSviVM4MGBzkUiE7UZ4/I6I/LkqGXUvmjRb+SDnGlGuVrCu76XoIShcypMOo9jcs8fabQ/hmh1LhW339QN9hpf8sfgq7KHIPpmOKvrKSGTIv3Tx2yUBjfeFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=coxR2aCm; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="coxR2aCm" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a2f79e79f0cso242428066b.2 for ; Thu, 01 Feb 2024 23:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706857374; x=1707462174; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=lBXjT/pjd5QCS7CfT4+C53H6bHqWr9YfEtVQDFTqXT0=; b=coxR2aCm0/ImsdTQGGHdhjPTYPcfOHgcoivaVLMaD3Tx9dRZ0ZxtichO1lWlrwWeP2 9wiLuxXajj0oXUxclYDFvwECZbqaM9V1U+9QgOYHsu5qxdtBQg8K9dXFCpbB5m4RDvYu jNY5lC/gfYeT2gFnfo3D9EQCTNUEU9Lb33Jdp8i4G2R92Y6TaC3Qenhmg6Bi9vSsSdcB bmXF7I8hdoPksH6WeOSWjOrep2FDERLJwZQDSXt44EuuPOfemnvV5MnctwJAolgvpiw3 ItO7EXnpZtEuArhRhPJ1Cbz1B9Wsr+cN/Ao7X3BO/1NkRpqdm5VTVNrjWlA/qlavOiL4 Xe+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706857374; x=1707462174; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lBXjT/pjd5QCS7CfT4+C53H6bHqWr9YfEtVQDFTqXT0=; b=bA580Nm60NXHz2sUmIdeB2UlUN1dMumNfUlNmYi8QJly7ubYI9lpHRGU1u/7OsPH9L 2igKbsfWRvMfdZxznqtavOD6eg4y914JRPTikvp2Tu6fzvuRNgLWh/u9QGIoDdNmx3q0 NKHoeUPstCuWO5J89HGbzIt7h6uRXkgbLpCk9RsatVzjRSidhwkdrMDbt4kQv7AHV57n 2uC05wr4wdfgJXKljGxsLInyWrOXxE+p2ubXNO/NuMikXg1lsamdNL/xQUkKDHv0Dr76 ZAwJViBi9g2+H93t3h9+Nx7OhvXi++MG0iZA0lkjWx0tomIN4zWSWI2ZF3CUGWe4NcKS p30Q== X-Gm-Message-State: AOJu0YwXlDqdIFaBPK7eCvsJLwovG9Khd+UBji0tBl7plRcwQcsLn03n j6L6DeETtEAUvKtQ6LR3b2GAgFanSMSh/YGpdaSxtYIjw7Pb169o X-Google-Smtp-Source: AGHT+IHU1bV3d5cBfjockxsOT3ByhTRuHH2tbtCBhe2+sPy6vmPOfpp7nMxX7apQV47aTuAv2jHfgQ== X-Received: by 2002:a17:906:680a:b0:a31:6587:8abe with SMTP id k10-20020a170906680a00b00a3165878abemr4950680ejr.48.1706857373623; Thu, 01 Feb 2024 23:02:53 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVkWKF4eMHZuFANT9BaQSUhLn0Zl5GmInZlvuwRZ5UpVsjrOcnCivqU2IqsfI6GaWaYIbddYCjeUTXrC0Hg7Vh6USKHaOhtWIdXwhUjHSk8AuU0Ghr0Mc6zIrkH5jWEjxiVaq9ENYDaOw== Received: from ?IPV6:2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea? (dynamic-2a01-0c22-7392-d000-5c1a-bcfc-a8a4-5bea.c22.pool.telefonica.de. [2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea]) by smtp.googlemail.com with ESMTPSA id c3-20020a170906340300b00a35a659cab5sm563728ejb.179.2024.02.01.23.02.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Feb 2024 23:02:53 -0800 (PST) Message-ID: <7dab4b92-c8b1-4e2e-b057-af4e8e1d7631@gmail.com> Date: Fri, 2 Feb 2024 08:02:55 +0100 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 3/5] i2c: i801: Split i801_block_transaction Content-Language: en-US From: Heiner Kallweit To: Jean Delvare , Andi Shyti Cc: "linux-i2c@vger.kernel.org" , Andy Shevchenko References: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> Autocrypt: addr=hkallweit1@gmail.com; keydata= xsFNBF/0ZFUBEAC0eZyktSE7ZNO1SFXL6cQ4i4g6Ah3mOUIXSB4pCY5kQ6OLKHh0FlOD5/5/ sY7IoIouzOjyFdFPnz4Bl3927ClT567hUJJ+SNaFEiJ9vadI6vZm2gcY4ExdIevYHWe1msJF MVE4yNwdS+UsPeCF/6CQQTzHc+n7DomE7fjJD5J1hOJjqz2XWe71fTvYXzxCFLwXXbBiqDC9 dNqOe5odPsa4TsWZ09T33g5n2nzTJs4Zw8fCy8rLqix/raVsqr8fw5qM66MVtdmEljFaJ9N8 /W56qGCp+H8Igk/F7CjlbWXiOlKHA25mPTmbVp7VlFsvsmMokr/imQr+0nXtmvYVaKEUwY2g 86IU6RAOuA8E0J5bD/BeyZdMyVEtX1kT404UJZekFytJZrDZetwxM/cAH+1fMx4z751WJmxQ J7mIXSPuDfeJhRDt9sGM6aRVfXbZt+wBogxyXepmnlv9K4A13z9DVLdKLrYUiu9/5QEl6fgI kPaXlAZmJsQfoKbmPqCHVRYj1lpQtDM/2/BO6gHASflWUHzwmBVZbS/XRs64uJO8CB3+V3fa cIivllReueGCMsHh6/8wgPAyopXOWOxbLsZ291fmZqIR0L5Y6b2HvdFN1Xhc+YrQ8TKK+Z4R mJRDh0wNQ8Gm89g92/YkHji4jIWlp2fwzCcx5+lZCQ1XdqAiHQARAQABzSZIZWluZXIgS2Fs bHdlaXQgPGhrYWxsd2VpdDFAZ21haWwuY29tPsLBjgQTAQgAOBYhBGxfqY/yOyXjyjJehXLe ig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pB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> i2c and smbus block transaction handling have little in common, therefore split this function to improve code readability. Signed-off-by: Heiner Kallweit Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-i801.c | 112 +++++++++++++++------------------- 1 file changed, 50 insertions(+), 62 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 156bace92..24eb187db 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -802,77 +802,65 @@ static int i801_simple_transaction(struct i801_priv *priv, union i2c_smbus_data return 0; } -/* Block transaction function */ -static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data *data, - u8 addr, u8 hstcmd, char read_write, int command) +static int i801_smbus_block_transaction(struct i801_priv *priv, union i2c_smbus_data *data, + u8 addr, u8 hstcmd, char read_write, int command) { - int result = 0; - unsigned char hostc; - if (read_write == I2C_SMBUS_READ && command == I2C_SMBUS_BLOCK_DATA) data->block[0] = I2C_SMBUS_BLOCK_MAX; else if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) return -EPROTO; - switch (command) { - case I2C_SMBUS_BLOCK_DATA: - i801_set_hstadd(priv, addr, read_write); - outb_p(hstcmd, SMBHSTCMD(priv)); - break; - case I2C_SMBUS_I2C_BLOCK_DATA: - /* - * NB: page 240 of ICH5 datasheet shows that the R/#W - * bit should be cleared here, even when reading. - * However if SPD Write Disable is set (Lynx Point and later), - * the read will fail if we don't set the R/#W bit. - */ - i801_set_hstadd(priv, addr, - priv->original_hstcfg & SMBHSTCFG_SPD_WD ? - read_write : I2C_SMBUS_WRITE); - if (read_write == I2C_SMBUS_READ) { - /* NB: page 240 of ICH5 datasheet also shows - * that DATA1 is the cmd field when reading - */ - outb_p(hstcmd, SMBHSTDAT1(priv)); - } else - outb_p(hstcmd, SMBHSTCMD(priv)); - - if (read_write == I2C_SMBUS_WRITE) { - /* set I2C_EN bit in configuration register */ - pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &hostc); - pci_write_config_byte(priv->pci_dev, SMBHSTCFG, - hostc | SMBHSTCFG_I2C_EN); - } else if (!(priv->features & FEATURE_I2C_BLOCK_READ)) { - dev_err(&priv->pci_dev->dev, - "I2C block read is unsupported!\n"); - return -EOPNOTSUPP; - } - break; - case I2C_SMBUS_BLOCK_PROC_CALL: + if (command == I2C_SMBUS_BLOCK_PROC_CALL) /* Needs to be flagged as write transaction */ i801_set_hstadd(priv, addr, I2C_SMBUS_WRITE); + else + i801_set_hstadd(priv, addr, read_write); + outb_p(hstcmd, SMBHSTCMD(priv)); + + if (priv->features & FEATURE_BLOCK_BUFFER) + return i801_block_transaction_by_block(priv, data, read_write, command); + else + return i801_block_transaction_byte_by_byte(priv, data, read_write, command); +} + +static int i801_i2c_block_transaction(struct i801_priv *priv, union i2c_smbus_data *data, + u8 addr, u8 hstcmd, char read_write, int command) +{ + int result; + u8 hostc; + + if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) + return -EPROTO; + /* + * NB: page 240 of ICH5 datasheet shows that the R/#W bit should be cleared here, + * even when reading. However if SPD Write Disable is set (Lynx Point and later), + * the read will fail if we don't set the R/#W bit. + */ + i801_set_hstadd(priv, addr, + priv->original_hstcfg & SMBHSTCFG_SPD_WD ? read_write : I2C_SMBUS_WRITE); + + /* NB: page 240 of ICH5 datasheet shows that DATA1 is the cmd field when reading */ + if (read_write == I2C_SMBUS_READ) + outb_p(hstcmd, SMBHSTDAT1(priv)); + else outb_p(hstcmd, SMBHSTCMD(priv)); - break; + + if (read_write == I2C_SMBUS_WRITE) { + /* set I2C_EN bit in configuration register */ + pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &hostc); + pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc | SMBHSTCFG_I2C_EN); + } else if (!(priv->features & FEATURE_I2C_BLOCK_READ)) { + pci_err(priv->pci_dev, "I2C block read is unsupported!\n"); + return -EOPNOTSUPP; } - /* Experience has shown that the block buffer can only be used for - SMBus (not I2C) block transactions, even though the datasheet - doesn't mention this limitation. */ - if ((priv->features & FEATURE_BLOCK_BUFFER) && - command != I2C_SMBUS_I2C_BLOCK_DATA) - result = i801_block_transaction_by_block(priv, data, - read_write, - command); - else - result = i801_block_transaction_byte_by_byte(priv, data, - read_write, - command); + /* Block buffer isn't supported for I2C block transactions */ + result = i801_block_transaction_byte_by_byte(priv, data, read_write, command); - if (command == I2C_SMBUS_I2C_BLOCK_DATA - && read_write == I2C_SMBUS_WRITE) { - /* restore saved configuration register value */ + /* restore saved configuration register value */ + if (read_write == I2C_SMBUS_WRITE) pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc); - } + return result; } @@ -903,10 +891,10 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, outb_p(inb_p(SMBAUXCTL(priv)) & (~SMBAUXCTL_CRC), SMBAUXCTL(priv)); - if (size == I2C_SMBUS_BLOCK_DATA || - size == I2C_SMBUS_I2C_BLOCK_DATA || - size == I2C_SMBUS_BLOCK_PROC_CALL) - ret = i801_block_transaction(priv, data, addr, command, read_write, size); + if (size == I2C_SMBUS_BLOCK_DATA || size == I2C_SMBUS_BLOCK_PROC_CALL) + ret = i801_smbus_block_transaction(priv, data, addr, command, read_write, size); + else if (size == I2C_SMBUS_I2C_BLOCK_DATA) + ret = i801_i2c_block_transaction(priv, data, addr, command, read_write, size); else ret = i801_simple_transaction(priv, data, addr, command, read_write, size); From patchwork Fri Feb 2 07:04:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 769344 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D214171DC for ; Fri, 2 Feb 2024 07:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857448; cv=none; b=fm9CdiHfyNyBx60imTMS5FSgg4WlTaW5uZd9fy6zj2bzYm9e3tTQcWwVb/dsucv2XGOOVmeZ5K8n1yNaxPaHQfkvSR2dTPrHKbKIy4UmQUuYobhBfaJk3sq0+DI1DK8fyeKY9tKxr0XwR9jLZK5x256YER0RNz7AG14R8WNDmVU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857448; c=relaxed/simple; bh=B6Qu0TCnqA4qwCcbjIirDQcSbwjV75MQrchziOJUKPg=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=LSiFMQzUX4ugI9uUH9EzrdTbVAClgUQ7tw/MD2/9JFWUVegq/YKVtABquX1uJYA1S5y87gHtOh0vMJKRTTm1h/XOtq+Kb+KvI07XywG2yR+7hfTHJm6fhajRoxDvcS5JPd8fbfSANv2Bar0nmt7+DbcOZWElwzxiEq2/IrdZyHs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=P3gwwH/9; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P3gwwH/9" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a35e65df2d8so234039866b.0 for ; Thu, 01 Feb 2024 23:04:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706857444; x=1707462244; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=V/D3Ff0Cu4iOaNHj5XI9RwoCc3FRzrRWDfHTEUSNZvg=; b=P3gwwH/9VwapTqp76yL5vB8scXNb2UN3Z81F2p581Q1XETR6+nNHJbkHagnAccHn5E BNIHkuG/Q1XDeni5Wc7chV3EeE0wxZwcEXgo23RMH73RAbAM0ZFqyJJqJRxYzGNvkdnF Dex7l8SRp8+ab01xRbT5DETvT4hnw4xIkSmwSOGSb7iPrnBM2LMtfGVg818QYKw9FL7j HjwNtdW2071opqfunfNlgkN+iSdnei7gfOhx0BwlOzKvsP09SLl+dkyz29zAVhDf1d02 fTZSbRJLTt46PbWru0+VRMzz5BJtWLRUUoZiRC7LG8/wigykiXgfYYcEK6TsSt7Kj8JO 4rBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706857444; x=1707462244; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=V/D3Ff0Cu4iOaNHj5XI9RwoCc3FRzrRWDfHTEUSNZvg=; b=KjibktsEVJLsRrRuaDiJpyBnW5D2jdtUIIXkBqGaHJF+XShHwbjTovsGVR57H47Y/f rmuaGyz+bhmQGmdqjShYsDN7929TkS3ZZsU6GqW+1HoHjKLJgzOlV2q/l8xYgW3/LOtQ Fv24E80tYs1YeqlTByztinHwxX1TYdNfgPvc84ah4tzianFSaHVN5I5TM3yq5QdFxiLp i0ffgDF7wfbQaGP5j0aF2Y8+CQ4HhthHR+pcz3klAMniFu/bSVtmA0rFWVnfIvcYLN3c mC1gaq/ylwEPC/cYwkvY3Z7mRmOeZ5rHHRvKdba+2DsB8KUWJgJFViZAx7FdSPyrqqxM 70bg== X-Gm-Message-State: AOJu0YzLcwsguvgoGcGjUH/+13ZeVjWA7Irc21M11pCJAP0xYZT2okM8 s+slugJ+euLuzyvykG8m5cZPmq3pUOsAmN02WdPBDKJw9ZsKhwai X-Google-Smtp-Source: AGHT+IEFYChIaVd0Iqy02qiDFBgVl8K6McznvmbVRzshmE/+HjzlAoW9fo++DUgLAIGDbGJMcGIjrg== X-Received: by 2002:a17:907:b9d4:b0:a2b:a7e:3496 with SMTP id xa20-20020a170907b9d400b00a2b0a7e3496mr843966ejc.28.1706857444122; Thu, 01 Feb 2024 23:04:04 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUmBLY2hFJ++zC6eh9tFbrlGcFGaSEN0wdB/5brlhXCpAmie9wvrFO0tMESz2+4OyhJ2MmjWowvAiu7ZJgJb6MI9DptJqfhcUi9va+JaYWBVrMl5InMl/YiOkr19TRxfH/U4CRskyUtOA== Received: from ?IPV6:2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea? (dynamic-2a01-0c22-7392-d000-5c1a-bcfc-a8a4-5bea.c22.pool.telefonica.de. [2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea]) by smtp.googlemail.com with ESMTPSA id c3-20020a170906340300b00a35a659cab5sm563728ejb.179.2024.02.01.23.04.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Feb 2024 23:04:03 -0800 (PST) Message-ID: <0af53713-4b30-458e-9970-260a38871506@gmail.com> Date: Fri, 2 Feb 2024 08:04:06 +0100 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 4/5] i2c: i801: Add SMBUS_LEN_SENTINEL Content-Language: en-US From: Heiner Kallweit To: Jean Delvare , Andi Shyti Cc: "linux-i2c@vger.kernel.org" , Andy Sh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lGVGpBHxFUwb /a4UjJBPtIwa4tWR8B1Ma36S8Jk456k2n1id7M0LQ+eqstmp6Y+UB+pt9NX6t0Slw1NCdYTW gJezWTVKF7pmTdXszXGxlc9kTrVUz04PqPjnYbv5UWuDd2eyzGjrrFOsJEi8OK2d2j4FfF++ AzOMdW09JVqejQARAQABwsF2BBgBCAAgFiEEbF+pj/I7JePKMl6Fct6KD1TwOgwFAl/0ZFUC GwwACgkQct6KD1TwOgxUfg//eAoYc0Vm4NrxymfcY30UjHVD0LgSvU8kUmXxil3qhFPS7KA+ y7tgcKLHOkZkXMX5MLFcS9+SmrAjSBBV8omKoHNo+kfFx/dUAtz0lot8wNGmWb+NcHeKM1eb nwUMOEa1uDdfZeKef/U/2uHBceY7Gc6zPZPWgXghEyQMTH2UhLgeam8yglyO+A6RXCh+s6ak Wje7Vo1wGK4eYxp6pwMPJXLMsI0ii/2k3YPEJPv+yJf90MbYyQSbkTwZhrsokjQEaIfjrIk3 rQRjTve/J62WIO28IbY/mENuGgWehRlTAbhC4BLTZ5uYS0YMQCR7v9UGMWdNWXFyrOB6PjSu Trn9MsPoUc8qI72mVpxEXQDLlrd2ijEWm7Nrf52YMD7hL6rXXuis7R6zY8WnnBhW0uCfhajx q+KuARXC0sDLztcjaS3ayXonpoCPZep2Bd5xqE4Ln8/COCslP7E92W1uf1EcdXXIrx1acg21 H/0Z53okMykVs3a8tECPHIxnre2UxKdTbCEkjkR4V6JyplTS47oWMw3zyI7zkaadfzVFBxk2 lo/Tny+FX1Azea3Ce7oOnRUEZtWSsUidtIjmL8YUQFZYm+JUIgfRmSpMFq8JP4VH43GXpB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> Add a sentinel length value that is used to check whether we should read and use the length value provided by the slave device. This simplifies the currently used checks. Signed-off-by: Heiner Kallweit Reviewed-by: Andi Shyti --- v2: - add comments v3: - fix comment style --- drivers/i2c/busses/i2c-i801.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 24eb187db..15d251288 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -205,6 +205,8 @@ #define STATUS_FLAGS (SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR | \ STATUS_ERROR_FLAGS) +#define SMBUS_LEN_SENTINEL (I2C_SMBUS_BLOCK_MAX + 1) + /* Older devices have their ID defined in */ #define PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS 0x02a3 #define PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS 0x06a3 @@ -541,9 +543,12 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, static void i801_isr_byte_done(struct i801_priv *priv) { if (priv->is_read) { - /* For SMBus block reads, length is received with first byte */ - if (((priv->cmd & 0x1c) == I801_BLOCK_DATA) && - (priv->count == 0)) { + /* + * At transfer start i801_smbus_block_transaction() marks + * the block length as invalid. Check for this sentinel value + * and read the block length from SMBHSTDAT0. + */ + if (priv->len == SMBUS_LEN_SENTINEL) { priv->len = inb_p(SMBHSTDAT0(priv)); if (priv->len < 1 || priv->len > I2C_SMBUS_BLOCK_MAX) { dev_err(&priv->pci_dev->dev, @@ -698,8 +703,12 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, if (status) return status; - if (i == 1 && read_write == I2C_SMBUS_READ - && command != I2C_SMBUS_I2C_BLOCK_DATA) { + /* + * At transfer start i801_smbus_block_transaction() marks + * the block length as invalid. Check for this sentinel value + * and read the block length from SMBHSTDAT0. + */ + if (len == SMBUS_LEN_SENTINEL) { len = inb_p(SMBHSTDAT0(priv)); if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { dev_err(&priv->pci_dev->dev, @@ -806,7 +815,8 @@ static int i801_smbus_block_transaction(struct i801_priv *priv, union i2c_smbus_ u8 addr, u8 hstcmd, char read_write, int command) { if (read_write == I2C_SMBUS_READ && command == I2C_SMBUS_BLOCK_DATA) - data->block[0] = I2C_SMBUS_BLOCK_MAX; + /* Mark block length as invalid */ + data->block[0] = SMBUS_LEN_SENTINEL; else if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) return -EPROTO; From patchwork Fri Feb 2 07:06:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 769675 Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 297AB17C67 for ; Fri, 2 Feb 2024 07:06:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857592; cv=none; b=FmO6lAw8ny99GHLPq2svkZOZHTuuMAPEy6k+BSpZilH6Skr1P4ZrUxN4Qf7S+K6h7ct16j51ME73RwLW9NTQD8Oq1p0U8ONKJTzIYmLwvcW7aDK9BCYCjS81rPsgJLi7gVx2GnP6bONzb9Op3M+oQSYO29p7bMQ0ejlti1g5xRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706857592; c=relaxed/simple; bh=dJWpJxmWVYgcHkY3YoLw4L9O6QS4Xq/IR5XUlCyZiAA=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=hZ6RmIbfywzYc68vaDIur7mYRB+toOm+1OvxIWj1QpgIYWlQyPJwYE3XZ4SA2SOM0Vcx76AhsyTNMx6Sx79zxf3OLyXZ57YcCIGHec3Kj60gKlUh4MpXJnJdKEa5RwZlLrmwJ5tUgjEHG3yuIWCb4rvh4zIqqeHzX41FRBMhvkI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RpFmY5E+; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RpFmY5E+" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a3604697d63so266565066b.3 for ; Thu, 01 Feb 2024 23:06:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706857589; x=1707462389; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=2P+2nWu3iGITgq75CUIQnkUJLgdxtzlwZ1tx/cks1Mw=; b=RpFmY5E+4DQC4pdMvFLwJnb0h8kH5D/s/AZSPSEorwDXW/LIp7TOVCXSXdnssAjFwh tx9hLa7TfnBTUZIP8vbj5vkfpzGNwVS0Uvd96eo9oTlPOBGVnFN3A86HfgjnrlMfunuz P3k+nKBSi9Unpk+TOE51ZnhZB/ETMu5/T+NfArcLRl/Y/0BQoDsm0x+N1RuJORNVK/AE 8LSb4wPd2Cv8H0LHtRJhhfKVcdgDrUMIMCjm+l/rFzFUmDvk10fOZ1cjg2J6gUq4AiyP kw0tkPWSTp8pbxRb3jAJmOK4XKQzGBrb3EnSYAYAizkr5l3Pnh+QdGsJ9MOxDdAUASyw iXmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706857589; x=1707462389; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2P+2nWu3iGITgq75CUIQnkUJLgdxtzlwZ1tx/cks1Mw=; b=jdKvLIy73SSj4cih4fS2fa73L7iieWkRIroIlGRk/c6BOr55y9MfgLYBzK8idTu+WF TJkkMEmPNHoNnOdQ4Qx7xkXKe6vIsDVGs1Q7iBe4MhN5oYOv97VZrRPEwQvE3MmKidHD NO6OvJ7IHxPP+p0cC+yKG4BU7+usmh0e+C+/pDm8VNIMPixLNXv/qY19O4cvAE54d/pU I6T21c9XaIPoU1PZZqkzBNlOLMzumVBwQealC+BjbxJzTtF+qwmprDK2kVt9z1wmiHV2 x2fAdSp6QT3jVQeNX1CFguzhaPsY9xKHt/tbEIeeB6R9BREf0Ocs7EjW+cEZqD/d6LL9 H7bw== X-Gm-Message-State: AOJu0Yy/nh2NozWyMtdnBjBD1O2kT8TSmHk0BCgKR2sLmHMGgDrwLUdz zsxOMw1t0L2ptitJxCVTIT0+QYkGObuszl2H6OJ4j4Rtb4bFScxx X-Google-Smtp-Source: AGHT+IFkEvNW0LIlSKYB5s907dm1q0yVmS+N5y7lEP3MfcIqf9bZV4f+9YR+AUrP5+C2UOcW24Bg7A== X-Received: by 2002:a17:906:bce7:b0:a31:45a6:2bb5 with SMTP id op7-20020a170906bce700b00a3145a62bb5mr4952665ejb.40.1706857588993; Thu, 01 Feb 2024 23:06:28 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCV/hmJnhgT+YerZWQc+655k1uTzMbo3XtRz5je6R0RsbQCCWGMLKXw5pJIK0FMuB1B3rZ/PV3oCNB608G6rQIz/RFrtnjv5cGQSi4l3VQAI7g7L/Cixr3x2pqeNJ4lFAgK4m2pEkqHpcQ== Received: from ?IPV6:2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea? (dynamic-2a01-0c22-7392-d000-5c1a-bcfc-a8a4-5bea.c22.pool.telefonica.de. [2a01:c22:7392:d000:5c1a:bcfc:a8a4:5bea]) by smtp.googlemail.com with ESMTPSA id c3-20020a170906340300b00a35a659cab5sm568494ejb.179.2024.02.01.23.06.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Feb 2024 23:06:28 -0800 (PST) Message-ID: Date: Fri, 2 Feb 2024 08:06:30 +0100 Precedence: bulk X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v3 5/5] i2c: i801: Add helper i801_get_block_len Content-Language: en-US From: Heiner Kallweit To: Jean Delvare , Andi Shyti Cc: "linux-i2c@vger.kernel.org" , Andy Shevchenko References: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> Autocrypt: addr=hkallweit1@gmail.com; keydata= xsFNBF/0ZFUBEAC0eZyktSE7ZNO1SFXL6cQ4i4g6Ah3mOUIXSB4pCY5kQ6OLKHh0FlOD5/5/ sY7IoIouzOjyFdFPnz4Bl3927ClT567hUJJ+SNaFEiJ9vadI6vZm2gcY4ExdIevYHWe1msJF MVE4yNwdS+UsPeCF/6CQQTzHc+n7DomE7fjJD5J1hOJjqz2XWe71fTvYXzxCFLwXXbBiqDC9 dNqOe5odPsa4TsWZ09T33g5n2nzTJs4Zw8fCy8rLqix/raVsqr8fw5qM66MVtdmEljFaJ9N8 /W56qGCp+H8Igk/F7CjlbWXiOlKHA25mPTmbVp7VlFsvsmMokr/imQr+0nXtmvYVaKEUwY2g 86IU6RAOuA8E0J5bD/BeyZdMyVEtX1kT404UJZekFytJZrDZetwxM/cAH+1fMx4z751WJmxQ J7mIXSPuDfeJhRDt9sGM6aRVfXbZt+wBogxyXepmnlv9K4A13z9DVLdKLrYUiu9/5QEl6fgI kPaXlAZmJsQfoKbmPqCHVRYj1lpQtDM/2/BO6gHASflWUHzwmBVZbS/XRs64uJO8CB3+V3fa cIivllReueGCMsHh6/8w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uARXC0sDLztcjaS3ayXonpoCPZep2Bd5xqE4Ln8/COCslP7E92W1uf1EcdXXIrx1acg21 H/0Z53okMykVs3a8tECPHIxnre2UxKdTbCEkjkR4V6JyplTS47oWMw3zyI7zkaadfzVFBxk2 lo/Tny+FX1Azea3Ce7oOnRUEZtWSsUidtIjmL8YUQFZYm+JUIgfRmSpMFq8JP4VH43GXpB/S OCrl+/xujzvoUBFV/cHKjEQYBxo+MaiQa1U54ykM2W4DnHb1UiEf5xDkFd4= In-Reply-To: <4e4ec801-474c-472f-b90d-edd1efd68d24@gmail.com> Avoid code duplication and factor out retrieving and checking the block length value to new helper i801_get_block_len(). Signed-off-by: Heiner Kallweit Reviewed-by: Andi Shyti --- v2: - in the error case go to label out instead of directly bailing out in i801_block_transaction_by_block() --- drivers/i2c/busses/i2c-i801.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 15d251288..918c794c7 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -330,6 +330,18 @@ MODULE_PARM_DESC(disable_features, "Disable selected driver features:\n" "\t\t 0x10 don't use interrupts\n" "\t\t 0x20 disable SMBus Host Notify "); +static int i801_get_block_len(struct i801_priv *priv) +{ + u8 len = inb_p(SMBHSTDAT0(priv)); + + if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { + pci_err(priv->pci_dev, "Illegal SMBus block read size %u\n", len); + return -EPROTO; + } + + return len; +} + static int i801_check_and_clear_pec_error(struct i801_priv *priv) { u8 status; @@ -525,12 +537,11 @@ static int i801_block_transaction_by_block(struct i801_priv *priv, if (read_write == I2C_SMBUS_READ || command == I2C_SMBUS_BLOCK_PROC_CALL) { - len = inb_p(SMBHSTDAT0(priv)); - if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { - status = -EPROTO; + status = i801_get_block_len(priv); + if (status < 0) goto out; - } + len = status; data->block[0] = len; for (i = 0; i < len; i++) data->block[i + 1] = inb_p(SMBBLKDAT(priv)); @@ -549,14 +560,11 @@ static void i801_isr_byte_done(struct i801_priv *priv) * and read the block length from SMBHSTDAT0. */ if (priv->len == SMBUS_LEN_SENTINEL) { - priv->len = inb_p(SMBHSTDAT0(priv)); - if (priv->len < 1 || priv->len > I2C_SMBUS_BLOCK_MAX) { - dev_err(&priv->pci_dev->dev, - "Illegal SMBus block read size %d\n", - priv->len); + priv->len = i801_get_block_len(priv); + if (priv->len < 0) /* FIXME: Recover */ priv->len = I2C_SMBUS_BLOCK_MAX; - } + priv->data[-1] = priv->len; } @@ -709,11 +717,8 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, * and read the block length from SMBHSTDAT0. */ if (len == SMBUS_LEN_SENTINEL) { - len = inb_p(SMBHSTDAT0(priv)); - if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { - dev_err(&priv->pci_dev->dev, - "Illegal SMBus block read size %d\n", - len); + len = i801_get_block_len(priv); + if (len < 0) { /* Recover */ while (inb_p(SMBHSTSTS(priv)) & SMBHSTSTS_HOST_BUSY)