From patchwork Thu Mar 24 16:19:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 64406 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp756923lbc; Thu, 24 Mar 2016 09:21:12 -0700 (PDT) X-Received: by 10.98.15.135 with SMTP id 7mr14033912pfp.142.1458836466483; Thu, 24 Mar 2016 09:21:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s28si13089334pfi.238.2016.03.24.09.21.06; Thu, 24 Mar 2016 09:21:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-i2c-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-i2c-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754314AbcCXQU6 (ORCPT + 1 other); Thu, 24 Mar 2016 12:20:58 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:37998 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756814AbcCXQT4 (ORCPT ); Thu, 24 Mar 2016 12:19:56 -0400 Received: by mail-wm0-f49.google.com with SMTP id l68so73705093wml.1 for ; Thu, 24 Mar 2016 09:19:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sS7RDPeLeR4blFSzM8gU2EtAZsv2Krrr+lbZPcXb6lw=; b=htU2mRQcilgwyUPMzi2gpX9Cum8Qj9AZfDyDUe8AuGn50c4AqnhHXICThKFHzbql89 EKIA5mo2H9eTuGaA4mbFBGTimFj5tx3BBA5CHWKDjWoWve0iRI7vRU5kbikWgu+raj+y sgTN8WxovQU03IQwILGg/YRGlViaODR7bBhg/81RACcaKCCBQbTZSS3Ykz+i9pFeotrb Dr6ja905PtQrJT+J58k9zjlZCYDdTvFfLIdhZC2n6XwGJ5UL6h8/bduH6/2p4Orc9hhZ HZQ7xVVJU7eyUlrVHUrqTWB+wHFgPKoklpRNPI9HYrKcAe/uu+ovwfva+zmgpRDjbJEa y4sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sS7RDPeLeR4blFSzM8gU2EtAZsv2Krrr+lbZPcXb6lw=; b=IVXn9oeuqYGPFvB3upYP0tpMxkv+PQW4mBuGvePhG5sqfFUl3myzJ7bgsdlodiyE04 s3ga2CmrOYKlsJN+SLLGTMjAw+TOFgsT1Y+CEvVJZN7jnOzuEP4S2xKllFPs3ptC1bz1 M84KSJ9duxedpFLvu3M2h9QNCjO4DqtRuCWDCODVDRYvnLZzz7xw0Q/DZAmJJUfS+j7m 5rSc+CY+YQT+xYofB6gmzfsMwXPhvGyRNLaEqKcmKwIdscMs7OXeohDnKs5YaEefTcsy nZheboApYQSFwLFKmkLyggYEGiY0KgXbyScSUgKBc3LGcfhNtQnH5+eMb1o7l8qnq0l2 DKTA== X-Gm-Message-State: AD7BkJJfL3cZB5z1D/p/QA05Le+zrUDtW1mvPkiko+WT/NcLv+XS2HEuclpRI8JNjG25ZeYL X-Received: by 10.194.223.104 with SMTP id qt8mr11035052wjc.11.1458836394335; Thu, 24 Mar 2016 09:19:54 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id k124sm8370718wmb.11.2016.03.24.09.19.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Mar 2016 09:19:53 -0700 (PDT) From: Bartosz Golaszewski To: Wolfram Sang , linux-i2c , LKML Cc: Andrew Lunn , Bartosz Golaszewski Subject: [PATCH v2 08/13] eeprom: at24: call read and write routines via function pointers Date: Thu, 24 Mar 2016 17:19:38 +0100 Message-Id: <1458836383-6668-9-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458836383-6668-1-git-send-email-bgolaszewski@baylibre.com> References: <1458836383-6668-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org In order to support non-standard read/write functions (as part of the at24cs series support) introduce two function pointers in struct at24_data to which different implementations can be assigned. For now we continue to use the regular read/write routines by default. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index fda5c56..4c868a2 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -59,6 +59,10 @@ struct at24_data { int use_smbus; int use_smbus_write; + ssize_t (*read_func)(struct at24_data *, char *, loff_t, size_t); + ssize_t (*write_func)(struct at24_data *, + const char *, loff_t, size_t); + u8 *writebuf; struct mutex wrbuf_lock; unsigned write_max; @@ -458,7 +462,7 @@ static int at24_regmap_read(void *context, const void *reg, size_t reg_size, off_t offset = *(u32 *)reg; int err; - err = at24_read(at24, val, offset, val_size); + err = at24->read_func(at24, val, offset, val_size); if (err) return err; return 0; @@ -476,7 +480,7 @@ static int at24_regmap_write(void *context, const void *data, size_t count) buf = (const char *)data + sizeof(offset); len = count - sizeof(offset); - err = at24_write(at24, buf, offset, len); + err = at24->write_func(at24, buf, offset, len); if (err) return err; return 0; @@ -611,6 +615,9 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) at24->chip = chip; at24->num_addresses = num_addresses; + at24->read_func = at24_read; + at24->write_func = at24_write; + writable = !(chip.flags & AT24_FLAG_READONLY); if (writable) { if (!use_smbus || use_smbus_write) {