From patchwork Thu Nov 16 20:26:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 838784 X-Patchwork-Delegate: bartekgola@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LpimsnzH"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ydCTl5MJXz9rxm for ; Fri, 17 Nov 2017 07:27:23 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759040AbdKPU1W (ORCPT ); Thu, 16 Nov 2017 15:27:22 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:39199 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759008AbdKPU1V (ORCPT ); Thu, 16 Nov 2017 15:27:21 -0500 Received: by mail-wm0-f66.google.com with SMTP id l8so2558275wmg.4 for ; Thu, 16 Nov 2017 12:27:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=Xjl8gm8IOuc8azzQ7wKi6uJHUf8C/SIq9jBW9mCxfbU=; b=LpimsnzHPht7+D/CulYWAlhsXa0CyY0V58dspRwwS2ZosMf0y6nB8t+5lmTKCNWxFt y+VdE4taZp8rSG5VeM86xUAiJ/YT3vSqYTkqixTUnUNfDNyhoRxeNXYszZhbw06ySxg7 k/bEUpmkXNyER8FU9DelouEV1i1IqdMf8recljmVV57yd2HsMg4kqVLgA+X5wRiU1ful wFb59Ga4E4NWadAomrmisdhu9Do6F/FBB9I/1M6Y8M9PHmzIM2CcgWu9J7HAK9cV5GiZ Iqi2cmJri4aE58Qqc6YhCGOjcMoyj+75GL9wPfkwXn5n5lJ9y0uK+AG/+HeuVg7BNQOj O8Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=Xjl8gm8IOuc8azzQ7wKi6uJHUf8C/SIq9jBW9mCxfbU=; b=ftZAWh8+vHpTSetenHfYfenCMQFVayiqMJBvICrno/Yy0f7zZ+k0X526dGpSPM6e1f 1fnWm48sKFGCKx807h8NHRgVaZn3FxfWyUur0SMXZwIIQfcli4gLuuj90jIQ9FA8j24Q Xz+mKCmEg/RrL5AASWLfkvlyIglK5DrGinnga/0yybJ3QXTEcv9aFK/hCZaROCkaUZdf bsvKY6F0a6GfCi+JPa0N8RwyATr7SdHmmwYJuVZHTUE+EhujFeTtByAaPl/TF5UW/X5M 3N9tQsnfk/KrprQwIda2V2noeoGpT/Dwv/8zGhJBjIc564tWpIxdy92HPi1Bb+XFTk6R lIig== X-Gm-Message-State: AJaThX5h+ySt5cjgYuB46VQ4PXwt99pBQk/HWlhoS2yB/J9jzIDyAj1A fbvZ6YPgXXYc0cwiH1KL68YW5A== X-Google-Smtp-Source: AGs4zMakzxqFkmySE2FUUrvB5wxm2F0gcArujESlnZXLdHz8lBK+7/XSmG8KnnZmihJ2zDXT5oWbQA== X-Received: by 10.28.112.22 with SMTP id l22mr2340464wmc.35.1510864039974; Thu, 16 Nov 2017 12:27:19 -0800 (PST) Received: from ?IPv6:2003:ea:8bc0:e400:5d3b:3d3e:54b7:39d0? (p200300EA8BC0E4005D3B3D3E54B739D0.dip0.t-ipconnect.de. [2003:ea:8bc0:e400:5d3b:3d3e:54b7:39d0]) by smtp.googlemail.com with ESMTPSA id m37sm2467635wrm.4.2017.11.16.12.27.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Nov 2017 12:27:19 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v2 3/7] eeprom: at24: add regmap-based write function To: Bartosz Golaszewski Cc: "linux-i2c@vger.kernel.org" References: Message-ID: Date: Thu, 16 Nov 2017 21:26:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add a regmap-based write function. Signed-off-by: Heiner Kallweit --- v2: - rebased --- drivers/misc/eeprom/at24.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 1411fa029..c0c59575e 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -525,6 +525,22 @@ static ssize_t at24_eeprom_write_smbus_byte(struct at24_data *at24, return -ETIMEDOUT; } +static ssize_t at24_regmap_write(struct at24_data *at24, const char *buf, + unsigned int offset, size_t count) +{ + unsigned long timeout, write_time; + struct regmap *regmap; + + regmap = at24_translate_offset(at24, &offset)->regmap; + count = at24_adjust_write_count(at24, offset, count); + + loop_until_timeout(timeout, write_time) + if (!regmap_bulk_write(regmap, offset, buf, count)) + return count; + + return -ETIMEDOUT; +} + static ssize_t at24_eeprom_write_i2c(struct at24_data *at24, const char *buf, unsigned int offset, size_t count) { @@ -636,7 +652,7 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) while (count) { int status; - status = at24->write_func(at24, buf, off, count); + status = at24_regmap_write(at24, buf, off, count); if (status < 0) { mutex_unlock(&at24->lock); pm_runtime_put(&client->dev);