Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp97972lqs; Thu, 13 Jun 2024 05:12:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW8L4uLvx9xxLRMAo/G9kYSmcMv2QdxamY7le1W+GjPrqeodK9s1QlLqCRCpBbtC6HvceMAe+QP2CYSw1KTKFl0dWmtIuiwMXGY8YFslg== X-Google-Smtp-Source: AGHT+IHx+TaqqH2i3cJ95MONQmDT8JsH3IgkQBUagBkJ7B6i+6F6OXczmQmchJXbAsKAlzHcmO9N X-Received: by 2002:a05:6830:4cc:b0:6f9:c212:c86c with SMTP id 46e09a7af769-6fa1be5ede0mr5077685a34.3.1718280722659; Thu, 13 Jun 2024 05:12:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718280722; cv=pass; d=google.com; s=arc-20160816; b=twWgA/Qv9ytlifbW3cuBkyiXANBtKnEibV7+H0Iv1uOvrlKdkJnFSJ4HwhG5gEKz36 8F4edT9n8lpBUwq+6CU/wqtdNkQCJrAP2JAiFrc6vaJghYNtNkzRtkc2yHP6aRtwZ1NX gKJOlzAqi/cL2NFgLhmMs+3qV/yc6iU0calvPRX+HwzSUTjICrkLED5+RW+oHJwvFI79 6pG9ikmgCGwt1hCjIXKGw357GmefEqxiXDoTH2b/NKh/tZGJn5EttXheEKPRAzTUsFxW cHA0xoMpQuUY/mrKMQFq1wBm8r1UxUC/o5GxLJrMQ+JRHWexUNEQKTcH1b7YupW9JEmG mw9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=oGodyiYjLAsD0yJbNMBI7MVLGuadjuXw3TChSJWxUzw=; fh=FNnzx3Zb18AoON4i5+qptanbAo6UnC0stZkE3DdZCKM=; b=ysfZM9K/i0jNR+oSmF6vByOUXaSHl/VZC+zGOKFGQvyU6KWGFW95Ic75VzRD4mZEvx 8p5gIG9WS5b3V02YOUO9VZNE4+/KEYDixnK+tX8c8kBkgqR+JzTcLndcUtslOLVDefey uYplseSaSCKc2n85riCo6qH27wp3rrUgGT03ip2CkW4TkGUabAbsi9WqzcDI3fMkq85b bUKCUhxgo+qWHH2EM/I9d7GLlxOvZD1FrUdzb/db3FuUHNO6XkiRrBaabvCxhNDnaVlj py8N0kp5A55m1yZjzZZQ09K3mWnmpvNFWSyKgE3Oxc9Vuc4om1x651gsh+/1TSSZ3UGF dVzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Y5KZGu0e; arc=pass (i=1 spf=pass spfdomain=flex--joychakr.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-213173-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213173-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-798ab9f96fcsi119860185a.377.2024.06.13.05.12.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 05:12:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213173-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Y5KZGu0e; arc=pass (i=1 spf=pass spfdomain=flex--joychakr.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-213173-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213173-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5BC8B1C2304D for ; Thu, 13 Jun 2024 12:12:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80EC6145B01; Thu, 13 Jun 2024 12:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Y5KZGu0e" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 4A888145A1B for ; Thu, 13 Jun 2024 12:07:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718280479; cv=none; b=fpffJ4eGmhq1Zo+srVpnOn3c9HjNoQ4T9xQb4Y9anr1ACq65ZUM5RCiU4fSwBov4IiPUkKy5+xmFPZLtx3ZoQJWLKYg18gRV14GqX/k8n2WFytulCb1266Xo3bk0bwoz6taXemh3Xi48aSdMN15lFHMoevLf9+r6pCC4wiHMS1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718280479; c=relaxed/simple; bh=ApfIUmMvEtf39ojiOQllZCMOwnzalBblmip9w0Xdo7w=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=VvBKw9kAKD9dO6klCsnkIRUu1ciQgZxyv0ol4pNufEdlUDEOXSwBWICzMsBiPyZZsCL7zL/+eIAQ4vEL+GvULNu5yAym/aD9ol+MmKAuBdjc4CIANJn6oCOyLl2P06FE4FywAmxJQEESDImOvsbG/dY0D8uu8PphWS9JVbCupAQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--joychakr.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Y5KZGu0e; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--joychakr.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dfe9ef3a637so1506179276.3 for ; Thu, 13 Jun 2024 05:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718280476; x=1718885276; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=oGodyiYjLAsD0yJbNMBI7MVLGuadjuXw3TChSJWxUzw=; b=Y5KZGu0eWU7udil0ghLJo1dz+yZJZd3vOg/d4XuoALJpL8oih1QPKMH2E0hqh34cPl zX2kggXpIOTjfibED34a7YAe5DETTBoU7YWyaVKXmUdloQc8t8EJ7sAs/A+FMey1a0eK O/50qErDCVAcUjAeOYUcyMmxlewXrHhJ/Tr8Zw6NRlXCrV+cXA5Yu5L1J2xf23e5D2V6 AfdAAWnccsCjGD+jslmcgvHw0dVvJ5TawZoIPA2dskdB44ljcDb2TgytmRLAGoywhQ78 9c0gnNgUYuUICaJkLRIbebXBd9vbu9AWAEUyCpTrgzzEWMbcU6oFWqDCd4lK88A7dbEG TD3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718280476; x=1718885276; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=oGodyiYjLAsD0yJbNMBI7MVLGuadjuXw3TChSJWxUzw=; b=m/quFnDRLx8gaFRWw+frNQorKqz8zcK+mgrLdENczln5UFDjNGK8LCMdggrLAMJHS5 m4zl18HjUA+EV02kieLDQhL9STWZ+ssP4l3NG2ondGBxL4EBOE4FSn2HrUcnJlE1e9/m taA9jivG0Tnlg5AM58jNGhz5EbUSnsOWYLPlFNNyxhpMtNxvpnGu5qw1kB2w5+v6Q25k 0ShkA/olr5cllQT4tbfocnIeVUSqx5j300Lc8W5E5sUnyNJ/1oniJv3+xXEiKrR4RGnj s6jbAztDZyQt7jYGf0TUJpji+9f3WPPdEmhwgw6mSFJ8Rhnk7cy3H3l4BxM+7N3Yc9bk G5EA== X-Forwarded-Encrypted: i=1; AJvYcCUwIhOXUPK8r1aNUW2EiyKZwc7ATCpaiEWdWfO4Z/K/GAk2CAswAj/keFOmI+t1ZPvN/RJ9r7gmCQxkIU0DwQTjDoNDEDJhe5FWRlc+ X-Gm-Message-State: AOJu0YxdUN9IwL3cceSNu/ilhMRS29XCl2Hr28xx2BbSpsBMy4rVUBs1 2zcOCd9kcJ8CVQkZ6Y9OQNR37q7otPgjhN3YoflkK/h+lITAxpkBu/Y1V20URgSc4hZJeymCwgL QNNoY8IIUJA== X-Received: from joychakr.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:6ea]) (user=joychakr job=sendgmr) by 2002:a05:6902:1001:b0:dfa:dec3:7480 with SMTP id 3f1490d57ef6-dfe69005926mr357042276.12.1718280476322; Thu, 13 Jun 2024 05:07:56 -0700 (PDT) Date: Thu, 13 Jun 2024 12:07:50 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Message-ID: <20240613120750.1455209-1-joychakr@google.com> Subject: [PATCH v2] rtc: abx80x: Fix return value of nvmem callback on read From: Joy Chakraborty To: Sean Anderson , Alexandre Belloni , Srinivas Kandagatla , Dan Carpenter Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Joy Chakraborty , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Read callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure. abx80x_nvmem_xfer() on read calls i2c_smbus_read_i2c_block_data() which returns the number of bytes read on success as per its api description, this return value is handled as an error and returned to nvmem even on success. Fix to handle all possible values that would be returned by i2c_smbus_read_i2c_block_data(). Fixes: e90ff8ede777 ("rtc: abx80x: Add nvmem support") Cc: stable@vger.kernel.org Signed-off-by: Joy Chakraborty --- drivers/rtc/rtc-abx80x.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c index fde2b8054c2e..1298962402ff 100644 --- a/drivers/rtc/rtc-abx80x.c +++ b/drivers/rtc/rtc-abx80x.c @@ -705,14 +705,18 @@ static int abx80x_nvmem_xfer(struct abx80x_priv *priv, unsigned int offset, if (ret) return ret; - if (write) + if (write) { ret = i2c_smbus_write_i2c_block_data(priv->client, reg, len, val); - else + if (ret) + return ret; + } else { ret = i2c_smbus_read_i2c_block_data(priv->client, reg, len, val); - if (ret) - return ret; + if (ret <= 0) + return ret ? ret : -EIO; + len = ret; + } offset += len; val += len; -- 2.45.2.505.gda0bf45e8d-goog