From patchwork Wed Oct 26 14:57:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antoine Tenart X-Patchwork-Id: 9397421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6DC3860236 for ; Wed, 26 Oct 2016 15:00:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BE1D29BF0 for ; Wed, 26 Oct 2016 15:00:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E87129C04; Wed, 26 Oct 2016 15:00:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1546029BF0 for ; Wed, 26 Oct 2016 15:00:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzPf1-0005DJ-2z; Wed, 26 Oct 2016 14:58:35 +0000 Received: from up.free-electrons.com ([163.172.77.33] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzPer-00052F-DC for linux-arm-kernel@lists.infradead.org; Wed, 26 Oct 2016 14:58:29 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 5B15E20C62; Wed, 26 Oct 2016 16:58:01 +0200 (CEST) Received: from localhost (unknown [163.172.35.26]) by mail.free-electrons.com (Postfix) with ESMTPSA id 2E89A20790; Wed, 26 Oct 2016 16:58:01 +0200 (CEST) From: Antoine Tenart To: maxime.ripard@free-electrons.com, pantelis.antoniou@konsulko.com, mark.rutland@arm.com, sboyd@codeaurora.org Subject: [RFC PATCH 5/5] of: overlay-mgr: add a detector for headers stored on a ds2431 eeprom over w1 Date: Wed, 26 Oct 2016 16:57:56 +0200 Message-Id: <20161026145756.21689-6-antoine.tenart@free-electrons.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161026145756.21689-1-antoine.tenart@free-electrons.com> References: <20161026145756.21689-1-antoine.tenart@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161026_075825_653272_39EE20E0 X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, devicetree@vger.kernel.org, Antoine Tenart , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Antoine Tenart --- drivers/of/overlay-manager/Kconfig | 10 ++++++++++ drivers/w1/slaves/w1_ds2431.c | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/of/overlay-manager/Kconfig b/drivers/of/overlay-manager/Kconfig index 1a36613c0c53..ad0a5b8e9e5e 100644 --- a/drivers/of/overlay-manager/Kconfig +++ b/drivers/of/overlay-manager/Kconfig @@ -16,4 +16,14 @@ config OF_OVERLAY_MGR_FORMAT_CHIP endmenu +menu "Overlay Manager detectors" + +config OF_OVERLAY_MGR_DETECTOR_DS2431 + bool "Dip header on a DS2431 EEPROM" + depends on W1_SLAVE_DS2431 + help + Enable dip header DS2431 EEPROM support. + +endmenu + endif diff --git a/drivers/w1/slaves/w1_ds2431.c b/drivers/w1/slaves/w1_ds2431.c index 80572cb63ba8..760325f9a2bd 100644 --- a/drivers/w1/slaves/w1_ds2431.c +++ b/drivers/w1/slaves/w1_ds2431.c @@ -15,6 +15,9 @@ #include #include #include +#include + +#include #include "../w1.h" #include "../w1_int.h" @@ -280,7 +283,43 @@ static const struct attribute_group *w1_f2d_groups[] = { NULL, }; +#if IS_ENABLED(CONFIG_OF_OVERLAY_MGR_DETECTOR_DS2431) +static int chip_dip_callback(struct w1_slave *sl) +{ + char **candidates = NULL; + int i, n, err = 0; + u8 *data; + + data = kzalloc(OVERLAY_MGR_DIP_MAX_SZ, GFP_KERNEL); + if (!data) + return -ENOMEM; + + /* sizeof(struct chip_header) is a mulitple of 8 */ + for (i = 0; i < OVERLAY_MGR_DIP_MAX_SZ; i += 8) { + if (w1_f2d_readblock(sl, i, 8, &data[i])) { + err = -EIO; + goto end; + } + } + + overlay_mgr_parse(&sl->dev, data, &candidates, &n); + if (!n) { + err = -EINVAL; + goto end; + } + + err = overlay_mgr_apply(&sl->dev, candidates, n); + +end: + kfree(data); + return err; +} +#endif + static struct w1_family_ops w1_f2d_fops = { +#if IS_ENABLED(CONFIG_OF_OVERLAY_MGR_DETECTOR_DS2431) + .callback = chip_dip_callback, +#endif .groups = w1_f2d_groups, };