From patchwork Mon Apr 11 18:57:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 65565 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1519377qge; Mon, 11 Apr 2016 11:59:53 -0700 (PDT) X-Received: by 10.66.62.106 with SMTP id x10mr11556115par.136.1460401191968; Mon, 11 Apr 2016 11:59:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5si4927336pfb.36.2016.04.11.11.59.51; Mon, 11 Apr 2016 11:59:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932191AbcDKS7u (ORCPT + 29 others); Mon, 11 Apr 2016 14:59:50 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:35151 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755129AbcDKS57 (ORCPT ); Mon, 11 Apr 2016 14:57:59 -0400 Received: by mail-pa0-f45.google.com with SMTP id td3so126583965pab.2 for ; Mon, 11 Apr 2016 11:57:58 -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=y/tZw8zj/fj1ADRP+ctgidXQlxJJimXwzpq9oBvk4HDdHmAa7RavwyWJ/SaZfVRmdk CoAW4K+R2DAmpZckxNOi32hsq2Akxe/okF0AwxoYK1XyXmowxyRrd62i819ATnj+j0vH 567hgSKfkPfTejUZzf0pbxBhdBgKTxnbsuMD+r1PjjtMkcJ5SMRr+ekLGr3jYgmzzANo Sm0g6PRQfY8legR6+wpNDSGv28oRv8oIJraFbuBWjfhnutzgECqrNWptFCz59GrKmI2W e7nFzGirpIXvMTwj3QHMgFQscPzRDqDr/0yGscO2wAl1WkdXMtSWs/MPjts4kDrLPtXX FfcA== 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=ON72dflg8Sb5LfgGg3njaGDY3CMCnpEBjn4YshBYY6vvbk6/mC1W/whgtW5OZKH3xf rnyzTNQB2Rfimx5D3DNmBXHeNHlH4t+ZgE3RhFYMxciPxiJd0s3vNosguCTa99UvK0ZF iCvzVRIM4UqtyuSgsUqnI4lIF5eDrewCWtFxZTY6gVvqg663sniotDgwrSg9sfkl7Fn/ jlJSWoC8ez+DBCCJbYQn7g39CMG7hPJCmcdPsS0D/CCJyRi2no1bZ9ikoiENNFy8ThYy Xus5GzUsBA/ZzidMtljhlwYh+E27QGc4UCDIi5qG7h4lQHWCFr5KFhEMRjc3n8NWp3OK IgGQ== X-Gm-Message-State: AD7BkJJRRI4x81mgBk8hG8bqBxnv8QAQPKhSiY0zFZ21kqycFasDOVOyN+wn2VWZMGa+C59+ X-Received: by 10.66.147.103 with SMTP id tj7mr34906660pab.72.1460401078378; Mon, 11 Apr 2016 11:57:58 -0700 (PDT) Received: from localhost.localdomain (cpe-172-248-200-249.socal.res.rr.com. [172.248.200.249]) by smtp.gmail.com with ESMTPSA id ke7sm22322404pad.44.2016.04.11.11.57.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Apr 2016 11:57:57 -0700 (PDT) From: Bartosz Golaszewski To: Wolfram Sang , linux-i2c , LKML , srinivas.kandagatla@linaro.org, maxime.ripard@free-electrons.com Cc: Andrew Lunn , Bartosz Golaszewski Subject: [RESEND PATCH v2 08/13] eeprom: at24: call read and write routines via function pointers Date: Mon, 11 Apr 2016 11:57:24 -0700 Message-Id: <1460401049-25459-9-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460401049-25459-1-git-send-email-bgolaszewski@baylibre.com> References: <1460401049-25459-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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) {