From patchwork Fri May 11 11:06:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 135523 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp719212lji; Fri, 11 May 2018 04:09:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo8nVVZ1dVgxxqkmeSn9VURhhA60Dcn3NdgZvz/iTYSC/famyYD+/GYuh76PuLiKSv1KJhX X-Received: by 2002:a63:7e08:: with SMTP id z8-v6mr171716pgc.383.1526036980084; Fri, 11 May 2018 04:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526036980; cv=none; d=google.com; s=arc-20160816; b=AlVvsdVqE2Sje89fzlbdYrKjAOD6+zVt90XV0ws/5Yt1+6ily/WcCOVc33GMnyK5vv hrCseuGheIUhRNKdgenIOxQSRjRjmL8+E6h/NqyG1mjhcJMCmzT2umH6iEIs5yvlb2UT 6WvZ50jdhP2Rz6TZna1Tra4ONyVDSThx7Ehq15O+OqsAlWlWKRe+cY2Xe3rs0xBEfqkf Z/SimJ9j78YIJUCTLVSyu3wgYM6JAzw2GnJG1gFGkenWBRxiKLqsx0x/5mkA4Ata+J8g fAIDzx2MU4kGv8qGyVyVxiszuCwhtRiVm79skKBanvWQaiX+uwgQR2Q2JtFBpxv2qcNx wQTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=SzJUKBPNwe/3NehlMvPVKfMBKPVrmxN/Paoe95Wq8jY=; b=HQ+ZS86dEmv2VozleDl5Mec1rtXox+/VMguo3HtvpnMV4sDxoXpGjPMJN+rEPdCtwS +YeNbLQwo/IyL5HcByZ1Uk3FW1B2SL0pYxAjKDnAPoPIcf9pbn+o4yOrvZ7rXnxcY395 iu1oYOsBEzOfA9Kmv8bBqttQIyboBS85qoXEndy82bH3hKyQ13yKV9LXQ4X0gRAQ9fQf enygZPf4qpqTigpaXfUXnFIG4GxVz6s72POxHgVQ6tBozxLhMUIb3DuUtQI5mBO8yhC3 CRJYHy9j6XKEXA5jYIPRZIg6W7ZSKlSHpOF4KAh4PAiiKiRJYfIUDRv4MxYWXJHnCwJr PcAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KrXt64vA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 82-v6si3059791pfs.40.2018.05.11.04.09.39; Fri, 11 May 2018 04:09:40 -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=@linaro.org header.s=google header.b=KrXt64vA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753467AbeEKLJi (ORCPT + 29 others); Fri, 11 May 2018 07:09:38 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:38861 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753372AbeEKLJb (ORCPT ); Fri, 11 May 2018 07:09:31 -0400 Received: by mail-wr0-f195.google.com with SMTP id 94-v6so4949633wrf.5 for ; Fri, 11 May 2018 04:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SzJUKBPNwe/3NehlMvPVKfMBKPVrmxN/Paoe95Wq8jY=; b=KrXt64vAVv0V2HpDysdipe1/xucwktRGpYBRKz/MDidhFw6E3M5YQxnBaMtyDFc/Bq NFEunrnw3uZWlQkb9S5fhUaDwfQAiWYKL3s+KCueqHRNMtp9QKMSafARWyewrjfhLv70 o597jSW3JtoFYB6vg6rTuAIaGWtHjHHfgb4LU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SzJUKBPNwe/3NehlMvPVKfMBKPVrmxN/Paoe95Wq8jY=; b=Te5jloreQX9jyt9RFE0+GzMCCDL7It4EX81YQ062VxRs2tfpb0HZpItLvBjedQhCV4 XLwWaye5iqjVga+sbRAnXq+dx+2zzx/spu1hRvlBblcR2YP345x3+4D0LIAUcxGYF00E wkjih0UdbqYyISm0qMxDR+bpFzhDlejQIqCEElMNilIJJUOid383FaUROkPSXp/dJSvZ KgMXjyQEF1lXwYaZkDB8uOl0xrr0meOu+dpQN/oJ4MTGo/LlEMBHjVZZzY/48LjQn6MS 4xEwKyKgzOW/qC7IVepivggN5dkfNpReJXBaYV4vJSLqkw3J8vZbfW3X2DwN4HOw7Y1N YqsQ== X-Gm-Message-State: ALKqPwfI+/8wKAukOZ4IUaKMidnfw0DSNa5UKh2QoaS0wL5F/2R1dLnE oU21Lfau61+2kEJb9luJWBD1frefdkA= X-Received: by 2002:adf:a789:: with SMTP id j9-v6mr3980040wrc.95.1526036969776; Fri, 11 May 2018 04:09:29 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id a129-v6sm714047wme.34.2018.05.11.04.09.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 04:09:29 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Andrew Lunn Subject: [PATCH 1/8] drivers: nvmem: Export nvmem_add_cells() Date: Fri, 11 May 2018 12:06:56 +0100 Message-Id: <20180511110703.4924-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> References: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Lunn Not all platforms use device tree. It is useful to be able to add cells to a NVMEM device from code. Export nvmem_add_cells() so making this possible. This required changing the parameters a bit, so that just the cells and the number of cells are passed, not the whole nvmem config structure. Signed-off-by: Andrew Lunn Reviewed-by: Andrey Smirnov Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 24 +++++++++++++++++------- include/linux/nvmem-provider.h | 11 +++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) -- 2.16.2 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index b05aa8e81303..b1c95ef78544 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -353,18 +353,27 @@ static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem, return 0; } -static int nvmem_add_cells(struct nvmem_device *nvmem, - const struct nvmem_config *cfg) +/** + * nvmem_add_cells() - Add cell information to an nvmem device + * + * @nvmem: nvmem device to add cells to. + * @info: nvmem cell info to add to the device + * @ncells: number of cells in info + * + * Return: 0 or negative error code on failure. + */ +int nvmem_add_cells(struct nvmem_device *nvmem, + const struct nvmem_cell_info *info, + int ncells) { struct nvmem_cell **cells; - const struct nvmem_cell_info *info = cfg->cells; int i, rval; - cells = kcalloc(cfg->ncells, sizeof(*cells), GFP_KERNEL); + cells = kcalloc(ncells, sizeof(*cells), GFP_KERNEL); if (!cells) return -ENOMEM; - for (i = 0; i < cfg->ncells; i++) { + for (i = 0; i < ncells; i++) { cells[i] = kzalloc(sizeof(**cells), GFP_KERNEL); if (!cells[i]) { rval = -ENOMEM; @@ -380,7 +389,7 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, nvmem_cell_add(cells[i]); } - nvmem->ncells = cfg->ncells; + nvmem->ncells = ncells; /* remove tmp array */ kfree(cells); @@ -393,6 +402,7 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, return rval; } +EXPORT_SYMBOL_GPL(nvmem_add_cells); /* * nvmem_setup_compat() - Create an additional binary entry in @@ -509,7 +519,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) } if (config->cells) - nvmem_add_cells(nvmem, config); + nvmem_add_cells(nvmem, config->cells, config->ncells); return nvmem; diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index f89598bc4e1c..24def6ad09bb 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -77,6 +77,9 @@ struct nvmem_device *devm_nvmem_register(struct device *dev, int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem); +int nvmem_add_cells(struct nvmem_device *nvmem, + const struct nvmem_cell_info *info, + int ncells); #else static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c) @@ -99,6 +102,14 @@ static inline int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem) { return nvmem_unregister(nvmem); + +} + +static inline int nvmem_add_cells(struct nvmem_device *nvmem, + const struct nvmem_cell_info *info, + int ncells) +{ + return -ENOSYS; } #endif /* CONFIG_NVMEM */ From patchwork Fri May 11 11:06:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 135529 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp723504lji; Fri, 11 May 2018 04:13:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpDZo3oa/Biln7s54sAT262hYozNTg4V6DRAwBzo9kFa2ff902cGTp01LIOBVuZW7Ajs2Xk X-Received: by 2002:a63:9711:: with SMTP id n17-v6mr4201342pge.431.1526037216201; Fri, 11 May 2018 04:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526037216; cv=none; d=google.com; s=arc-20160816; b=Im4b5KlworMaakn1Bfkli84KlcOlAFVLuLS42Bby66c3pQY1uUnefjbBhNJXB6aOpH z5orL2tK75SxQVu36CMPvbUFACqRlz5DzZIdn+J+BzOzvddHx/jhC+BXQbyl8cYxY3jP v1pgNa5bgo8iTpI9a+qqf3DyQxVMHnQJ4C5t/tDoLixKWqkoRy9H3DY8w27fPBZlB6UT Q9HLChFQmc5leWbyiy1FK2Carq1cfs475K7Ud9UH8aj1aKi7rhEK8pSdlBZJJMHsJz/H +7tSG1Io+nRPrwil9V0LgkSWYN8W9NYE/jtzg9h8+1nJYu7M2Rj0ji/8zIBuckjux6qY IIYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=VwzKhZgF5B3zqhxC+I0FIaUy5JAqnE+AvbHnfDdBwIo=; b=yke4rA2YVYV8++4j/5Dm1M8uMWpJf9KDd34V/p3Tg3XsRcVVlnQG80sU1K3HDwIoFA 9XyweQHqz8V2gDO45i4CJG3vP6mTlmxhNwOuq1S/7LaOQ2YuY88qpBEEuJvTv/+9eatP bYljzNDZFutIS89AS/WuVnsI9FimGhcvqAUbLjVVCZXbPt9VRI2rFrhgw6+9XpWTH3Jz 6sXZpXkDPy8VCz08DH361jg3UEfROdQQREZYycsCK4fFfB1wW3ahugWVT15oQ4p931HX QAO+qtj+/MRBHm6JeiYO0rcRo4tymz8eoccUERIb6wh7Ff9cM1Lk4OmkSl9LNUcb019S 7+vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hPY/OMRG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15-v6si2286766pgc.463.2018.05.11.04.13.35; Fri, 11 May 2018 04:13:36 -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=@linaro.org header.s=google header.b=hPY/OMRG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753710AbeEKLNd (ORCPT + 29 others); Fri, 11 May 2018 07:13:33 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55862 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753391AbeEKLJd (ORCPT ); Fri, 11 May 2018 07:09:33 -0400 Received: by mail-wm0-f66.google.com with SMTP id a8-v6so2112736wmg.5 for ; Fri, 11 May 2018 04:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VwzKhZgF5B3zqhxC+I0FIaUy5JAqnE+AvbHnfDdBwIo=; b=hPY/OMRG832axUfECemJMNg8p6NYoSceRWw+Qv9wo7Q35mTQCoKoLAPdZ0GdhQEJ22 WEahr9g9DMlTgVNXwV7o/CgeZ0TuN2h/V+MA3MQhPGi0SUwGDICrCSFbUDJmoeqVihD7 B18ktGQy218CWQzIgDo8oFdtETWNFog8MykF0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VwzKhZgF5B3zqhxC+I0FIaUy5JAqnE+AvbHnfDdBwIo=; b=NA9nRig2l1q5xz9DNr2SZK2n161DM4jkv9Ua7xr9qkXs3x7i/hogIDuyKp0nlqU0uT CeSmVu9tA3si7E/hbec7uJtXNB+Kewa1s5CvihOhxPmBccCL/jCFvIpNdmI7dm6OEcyJ nzlSBFk3PmZ7Us1b/cDO74TCdTPRLESznr7HHpuKkhQ0+4nJelPP/ozfYAgViHE6cx9r 1CXSReHapS/TJ7cKy9qkGv1JWcRCDuyjmXCczhERdHno8HHYr6mZRBX0u0gxtfkzzRrc LFemWDrdOR0GiMepMUe2fmNYMklIdqq82TcDCh9GHCAOcVemER0oagzuMWtvi9+uIt/F Wotw== X-Gm-Message-State: ALKqPwcN2oRcT/iXhZ601TgTq5CaPPuVUkiglNQfBts9an0tihLR4Azd Yv14E/37ytejlzzS7O0PMJ+vtQ== X-Received: by 2002:a1c:6803:: with SMTP id d3-v6mr1765686wmc.70.1526036972433; Fri, 11 May 2018 04:09:32 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id a129-v6sm714047wme.34.2018.05.11.04.09.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 04:09:31 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Andrey Smirnov , Chris Healy , Lucas Stach , Aleksander Morgado Subject: [PATCH 3/8] nvmem: Add RAVE SP EEPROM driver Date: Fri, 11 May 2018 12:06:58 +0100 Message-Id: <20180511110703.4924-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> References: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Smirnov Add driver providing access to EEPROMs connected to RAVE SP devices Cc: Srinivas Kandagatla Cc: linux-kernel@vger.kernel.org Cc: Chris Healy Cc: Lucas Stach Cc: Aleksander Morgado Signed-off-by: Andrey Smirnov Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/Kconfig | 6 + drivers/nvmem/Makefile | 3 + drivers/nvmem/rave-sp-eeprom.c | 357 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 366 insertions(+) create mode 100644 drivers/nvmem/rave-sp-eeprom.c -- 2.16.2 diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 1090924efdb1..54a3c298247b 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -175,4 +175,10 @@ config NVMEM_SNVS_LPGPR This driver can also be built as a module. If so, the module will be called nvmem-snvs-lpgpr. +config RAVE_SP_EEPROM + tristate "Rave SP EEPROM Support" + depends on RAVE_SP_CORE + help + Say y here to enable Rave SP EEPROM support. + endif diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index e54dcfa6565a..27e96a8efd1c 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -37,3 +37,6 @@ obj-$(CONFIG_MESON_MX_EFUSE) += nvmem_meson_mx_efuse.o nvmem_meson_mx_efuse-y := meson-mx-efuse.o obj-$(CONFIG_NVMEM_SNVS_LPGPR) += nvmem_snvs_lpgpr.o nvmem_snvs_lpgpr-y := snvs_lpgpr.o +obj-$(CONFIG_RAVE_SP_EEPROM) += nvmem-rave-sp-eeprom.o +nvmem-rave-sp-eeprom-y := rave-sp-eeprom.o + diff --git a/drivers/nvmem/rave-sp-eeprom.c b/drivers/nvmem/rave-sp-eeprom.c new file mode 100644 index 000000000000..50aeea6ec6cc --- /dev/null +++ b/drivers/nvmem/rave-sp-eeprom.c @@ -0,0 +1,357 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/* + * EEPROM driver for RAVE SP + * + * Copyright (C) 2018 Zodiac Inflight Innovations + * + */ +#include +#include +#include +#include +#include +#include +#include + +/** + * enum rave_sp_eeprom_access_type - Supported types of EEPROM access + * + * @RAVE_SP_EEPROM_WRITE: EEPROM write + * @RAVE_SP_EEPROM_READ: EEPROM read + */ +enum rave_sp_eeprom_access_type { + RAVE_SP_EEPROM_WRITE = 0, + RAVE_SP_EEPROM_READ = 1, +}; + +/** + * enum rave_sp_eeprom_header_size - EEPROM command header sizes + * + * @RAVE_SP_EEPROM_HEADER_SMALL: EEPROM header size for "small" devices (< 8K) + * @RAVE_SP_EEPROM_HEADER_BIG: EEPROM header size for "big" devices (> 8K) + */ +enum rave_sp_eeprom_header_size { + RAVE_SP_EEPROM_HEADER_SMALL = 4U, + RAVE_SP_EEPROM_HEADER_BIG = 5U, +}; + +#define RAVE_SP_EEPROM_PAGE_SIZE 32U + +/** + * struct rave_sp_eeprom_page - RAVE SP EEPROM page + * + * @type: Access type (see enum rave_sp_eeprom_access_type) + * @success: Success flag (Success = 1, Failure = 0) + * @data: Read data + + * Note this structure corresponds to RSP_*_EEPROM payload from RAVE + * SP ICD + */ +struct rave_sp_eeprom_page { + u8 type; + u8 success; + u8 data[RAVE_SP_EEPROM_PAGE_SIZE]; +} __packed; + +/** + * struct rave_sp_eeprom - RAVE SP EEPROM device + * + * @sp: Pointer to parent RAVE SP device + * @mutex: Lock protecting access to EEPROM + * @address: EEPROM device address + * @header_size: Size of EEPROM command header for this device + * @dev: Pointer to corresponding struct device used for logging + */ +struct rave_sp_eeprom { + struct rave_sp *sp; + struct mutex mutex; + u8 address; + unsigned int header_size; + struct device *dev; +}; + +/** + * rave_sp_eeprom_io - Low-level part of EEPROM page access + * + * @eeprom: EEPROM device to write to + * @type: EEPROM access type (read or write) + * @idx: number of the EEPROM page + * @page: Data to write or buffer to store result (via page->data) + * + * This function does all of the low-level work required to perform a + * EEPROM access. This includes formatting correct command payload, + * sending it and checking received results. + * + * Returns zero in case of success or negative error code in + * case of failure. + */ +static int rave_sp_eeprom_io(struct rave_sp_eeprom *eeprom, + enum rave_sp_eeprom_access_type type, + u16 idx, + struct rave_sp_eeprom_page *page) +{ + const bool is_write = type == RAVE_SP_EEPROM_WRITE; + const unsigned int data_size = is_write ? sizeof(page->data) : 0; + const unsigned int cmd_size = eeprom->header_size + data_size; + const unsigned int rsp_size = + is_write ? sizeof(*page) - sizeof(page->data) : sizeof(*page); + unsigned int offset = 0; + u8 cmd[cmd_size]; + int ret; + + cmd[offset++] = eeprom->address; + cmd[offset++] = 0; + cmd[offset++] = type; + cmd[offset++] = idx; + + /* + * If there's still room in this command's header it means we + * are talkin to EEPROM that uses 16-bit page numbers and we + * have to specify index's MSB in payload as well. + */ + if (offset < eeprom->header_size) + cmd[offset++] = idx >> 8; + /* + * Copy our data to write to command buffer first. In case of + * a read data_size should be zero and memcpy would become a + * no-op + */ + memcpy(&cmd[offset], page->data, data_size); + + ret = rave_sp_exec(eeprom->sp, cmd, cmd_size, page, rsp_size); + if (ret) + return ret; + + if (page->type != type) + return -EPROTO; + + if (!page->success) + return -EIO; + + return 0; +} + +/** + * rave_sp_eeprom_page_access - Access single EEPROM page + * + * @eeprom: EEPROM device to access + * @type: Access type to perform (read or write) + * @offset: Offset within EEPROM to access + * @data: Data buffer + * @data_len: Size of the data buffer + * + * This function performs a generic access to a single page or a + * portion thereof. Requested access MUST NOT cross the EEPROM page + * boundary. + * + * Returns zero in case of success or negative error code in + * case of failure. + */ +static int +rave_sp_eeprom_page_access(struct rave_sp_eeprom *eeprom, + enum rave_sp_eeprom_access_type type, + unsigned int offset, u8 *data, + size_t data_len) +{ + const unsigned int page_offset = offset % RAVE_SP_EEPROM_PAGE_SIZE; + const unsigned int page_nr = offset / RAVE_SP_EEPROM_PAGE_SIZE; + struct rave_sp_eeprom_page page; + int ret; + + /* + * This function will not work if data access we've been asked + * to do is crossing EEPROM page boundary. Normally this + * should never happen and getting here would indicate a bug + * in the code. + */ + if (WARN_ON(data_len > sizeof(page.data) - page_offset)) + return -EINVAL; + + if (type == RAVE_SP_EEPROM_WRITE) { + /* + * If doing a partial write we need to do a read first + * to fill the rest of the page with correct data. + */ + if (data_len < RAVE_SP_EEPROM_PAGE_SIZE) { + ret = rave_sp_eeprom_io(eeprom, RAVE_SP_EEPROM_READ, + page_nr, &page); + if (ret) + return ret; + } + + memcpy(&page.data[page_offset], data, data_len); + } + + ret = rave_sp_eeprom_io(eeprom, type, page_nr, &page); + if (ret) + return ret; + + /* + * Since we receive the result of the read via 'page.data' + * buffer we need to copy that to 'data' + */ + if (type == RAVE_SP_EEPROM_READ) + memcpy(data, &page.data[page_offset], data_len); + + return 0; +} + +/** + * rave_sp_eeprom_access - Access EEPROM data + * + * @eeprom: EEPROM device to access + * @type: Access type to perform (read or write) + * @offset: Offset within EEPROM to access + * @data: Data buffer + * @data_len: Size of the data buffer + * + * This function performs a generic access (either read or write) at + * arbitrary offset (not necessary page aligned) of arbitrary length + * (is not constrained by EEPROM page size). + * + * Returns zero in case of success or negative error code in case of + * failure. + */ +static int rave_sp_eeprom_access(struct rave_sp_eeprom *eeprom, + enum rave_sp_eeprom_access_type type, + unsigned int offset, u8 *data, + unsigned int data_len) +{ + unsigned int residue; + unsigned int chunk; + unsigned int head; + int ret; + + mutex_lock(&eeprom->mutex); + + head = offset % RAVE_SP_EEPROM_PAGE_SIZE; + residue = data_len; + + do { + /* + * First iteration, if we are doing an access that is + * not 32-byte aligned, we need to access only data up + * to a page boundary to avoid corssing it in + * rave_sp_eeprom_page_access() + */ + if (unlikely(head)) { + chunk = RAVE_SP_EEPROM_PAGE_SIZE - head; + /* + * This can only happen once per + * rave_sp_eeprom_access() call, so we set + * head to zero to process all the other + * iterations normally. + */ + head = 0; + } else { + chunk = RAVE_SP_EEPROM_PAGE_SIZE; + } + + /* + * We should never read more that 'residue' bytes + */ + chunk = min(chunk, residue); + ret = rave_sp_eeprom_page_access(eeprom, type, offset, + data, chunk); + if (ret) + goto out; + + residue -= chunk; + offset += chunk; + data += chunk; + } while (residue); +out: + mutex_unlock(&eeprom->mutex); + return ret; +} + +static int rave_sp_eeprom_reg_read(void *eeprom, unsigned int offset, + void *val, size_t bytes) +{ + return rave_sp_eeprom_access(eeprom, RAVE_SP_EEPROM_READ, + offset, val, bytes); +} + +static int rave_sp_eeprom_reg_write(void *eeprom, unsigned int offset, + void *val, size_t bytes) +{ + return rave_sp_eeprom_access(eeprom, RAVE_SP_EEPROM_WRITE, + offset, val, bytes); +} + +static int rave_sp_eeprom_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct rave_sp *sp = dev_get_drvdata(dev->parent); + struct device_node *np = dev->of_node; + struct nvmem_config config = { 0 }; + struct rave_sp_eeprom *eeprom; + struct nvmem_device *nvmem; + u32 reg[2], size; + + if (of_property_read_u32_array(np, "reg", reg, ARRAY_SIZE(reg))) { + dev_err(dev, "Failed to parse \"reg\" property\n"); + return -EINVAL; + } + + size = reg[1]; + /* + * Per ICD, we have no more than 2 bytes to specify EEPROM + * page. + */ + if (size > U16_MAX * RAVE_SP_EEPROM_PAGE_SIZE) { + dev_err(dev, "Specified size is too big\n"); + return -EINVAL; + } + + eeprom = devm_kzalloc(dev, sizeof(*eeprom), GFP_KERNEL); + if (!eeprom) + return -ENOMEM; + + eeprom->address = reg[0]; + eeprom->sp = sp; + eeprom->dev = dev; + + if (size > SZ_8K) + eeprom->header_size = RAVE_SP_EEPROM_HEADER_BIG; + else + eeprom->header_size = RAVE_SP_EEPROM_HEADER_SMALL; + + mutex_init(&eeprom->mutex); + + config.id = -1; + of_property_read_string(np, "zii,eeprom-name", &config.name); + config.priv = eeprom; + config.dev = dev; + config.size = size; + config.reg_read = rave_sp_eeprom_reg_read; + config.reg_write = rave_sp_eeprom_reg_write; + config.word_size = 1; + config.stride = 1; + + nvmem = devm_nvmem_register(dev, &config); + + return PTR_ERR_OR_ZERO(nvmem); +} + +static const struct of_device_id rave_sp_eeprom_of_match[] = { + { .compatible = "zii,rave-sp-eeprom" }, + {} +}; +MODULE_DEVICE_TABLE(of, rave_sp_eeprom_of_match); + +static struct platform_driver rave_sp_eeprom_driver = { + .probe = rave_sp_eeprom_probe, + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = rave_sp_eeprom_of_match, + }, +}; +module_platform_driver(rave_sp_eeprom_driver); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Andrey Vostrikov "); +MODULE_AUTHOR("Nikita Yushchenko "); +MODULE_AUTHOR("Andrey Smirnov "); +MODULE_DESCRIPTION("RAVE SP EEPROM driver"); From patchwork Fri May 11 11:06:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 135528 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp722309lji; Fri, 11 May 2018 04:12:26 -0700 (PDT) X-Google-Smtp-Source: AB8JxZodqDwxXNHSjIrE7cJfzKnMdpkjtRX66EE1bIlbiuvVqcQvkSAtpnZMqXacrngcjKCRila6 X-Received: by 2002:a62:ec18:: with SMTP id k24-v6mr5091769pfh.204.1526037146148; Fri, 11 May 2018 04:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526037146; cv=none; d=google.com; s=arc-20160816; b=v0bGFt8Nbs9b2kdrPGeNC82rJ2w3FHTrdYKwCeyD6+eYeTnqdoYrc5t9PGSczWlos6 EgVJCl5v6GcJ5eiNlA53uet1rdZ5cMGVc+MHbD7DuXKH8kpv6gbVhCUWldD3vGfM3vlB P3zZ5pNpOKPl5oq6EhYmc0qvfmxnIODvhwECmEC/eFk79/SRsbKV1Wq0fNnCmkJMaRlX 4gdIdttkk3BKu7CE9FFNe3vU/B2RoUipmUk/mBn4M4m/ALbMS1yRGYfGFsU8GWB3qrLl y3sasmYSZxDYL0t6yiFA94eM8T1u93ij12XEn1CMDlS6dqozzaR7ivDM2Sf74weNFiYO 5dyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=H0qz3G2Yf+qnI2Pb4BPJFyzQj57UjzkRbyWc8uQk8Mg=; b=OmoWePhgREiCrV8Tvd2bnZnqEK42y3p4Q9kiG7DsSC27pVes6bmJ7+js5STGGr87b9 2BTGs4+Nvli3OsG0Q4rgOg9iCPKx2OcviJQVcpZo8X7osh9e3VXHWfG86K5XTrFuRHyW 2964FXFM8c2BiEdplxleWxDkc9oKBxK0ZblFXs0JfFttZawGrkoH/VZXX9IaVY4MNzai NRNqCJ2SNtiKZx+q/YR1hw+gOkK44/C9Ac1GxDj/wHx1YFFETaJhxPEeOfBEYp/rtlv2 e27xQh9t97Tj/8Me+WG19R4QRMDrTbXDh8Mbu5qIFF4mnVETfxFc4KUSEFKNX8+K17lT 7d4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jaBGao1Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10-v6si3035584plo.150.2018.05.11.04.12.25; Fri, 11 May 2018 04:12:26 -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=@linaro.org header.s=google header.b=jaBGao1Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753672AbeEKLMW (ORCPT + 29 others); Fri, 11 May 2018 07:12:22 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53856 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753401AbeEKLJe (ORCPT ); Fri, 11 May 2018 07:09:34 -0400 Received: by mail-wm0-f68.google.com with SMTP id a67-v6so2114042wmf.3 for ; Fri, 11 May 2018 04:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H0qz3G2Yf+qnI2Pb4BPJFyzQj57UjzkRbyWc8uQk8Mg=; b=jaBGao1QX42V6f9SJylLu6sI4TdwcCpxhbxPXyVzD1WwX9uKENbRnWvYuXQfmqvDmL Z9VOKWD4yjcl+BI/yLJ3u2eakvju+QXtA/aaHQctuhdHj/MVbuqwiMNmSDaWs57Yg6Zu 35LpLP/CHK1/A0lcNBFSN9RmFBitoIz7B48W0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H0qz3G2Yf+qnI2Pb4BPJFyzQj57UjzkRbyWc8uQk8Mg=; b=f94P2/yosCtTyN7GgkvS/OlBQw3EU0mfwk7IybADc1SUbDeyinKfHQalDlb13FJy0a CmS2i5mVb+nmt+RnmurgntOIGGVA5398mXGUzxBtOgIoiPPEjgsz3g991/cKTDcNTSTf dPtAOpkN8vRyKJJMSh5I5j45UpAuiJ6pLFWJ1WPQoh9UW9CLL4+CLntxf1EpIBhh/+p/ 5IgYQameAmdnH/IhMprMGGKSEVBYTYuIYsQWf7MvwII4O64N17lvY4qwmbOOecqHbJrF NmidmNb5U5l0woIUod1cu1Rfx58sBrf1u9fI2WT3a7EMKkisRwqwyuLytZdt0GysgZAs n1Gg== X-Gm-Message-State: ALKqPwdz+TEqiOraK9/U25Xeht9S4gG+teoOsaxx5nLZGWLAOqbuJx4B mO4xoi76/sg7+gg4BMsOLNzMKg== X-Received: by 2002:a1c:d810:: with SMTP id p16-v6mr1674905wmg.133.1526036973303; Fri, 11 May 2018 04:09:33 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id a129-v6sm714047wme.34.2018.05.11.04.09.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 04:09:32 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Jerome Brunet Subject: [PATCH 4/8] nvmem: meson-efuse: remove econfig global Date: Fri, 11 May 2018 12:06:59 +0100 Message-Id: <20180511110703.4924-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> References: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerome Brunet Having a global structure holding a reference to the device structure is not very nice. Allocate the econfig instead and fill the nvmem information as before Reviewed-by: Kevin Hilman Signed-off-by: Jerome Brunet Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/meson-efuse.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) -- 2.16.2 diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c index 71823d1403c5..2df9b0094f45 100644 --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -35,13 +35,6 @@ static int meson_efuse_read(void *context, unsigned int offset, return 0; } -static struct nvmem_config econfig = { - .name = "meson-efuse", - .stride = 1, - .word_size = 1, - .read_only = true, -}; - static const struct of_device_id meson_efuse_match[] = { { .compatible = "amlogic,meson-gxbb-efuse", }, { /* sentinel */ }, @@ -50,17 +43,27 @@ MODULE_DEVICE_TABLE(of, meson_efuse_match); static int meson_efuse_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct nvmem_device *nvmem; + struct nvmem_config *econfig; unsigned int size; if (meson_sm_call(SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) return -EINVAL; - econfig.dev = &pdev->dev; - econfig.reg_read = meson_efuse_read; - econfig.size = size; + econfig = devm_kzalloc(dev, sizeof(*econfig), GFP_KERNEL); + if (!econfig) + return -ENOMEM; + + econfig->dev = dev; + econfig->name = dev_name(dev); + econfig->stride = 1; + econfig->word_size = 1; + econfig->read_only = true; + econfig->reg_read = meson_efuse_read; + econfig->size = size; - nvmem = devm_nvmem_register(&pdev->dev, &econfig); + nvmem = devm_nvmem_register(&pdev->dev, econfig); return PTR_ERR_OR_ZERO(nvmem); } From patchwork Fri May 11 11:07:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 135527 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp721970lji; Fri, 11 May 2018 04:12:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrP1gJCqpWHEyi5IHMKJW92hpexfK5zqm6FP5/6aVIU5j/5frc811NORJmZ+pMdvV+5CPW/ X-Received: by 2002:a63:4384:: with SMTP id q126-v6mr4028143pga.294.1526037126005; Fri, 11 May 2018 04:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526037125; cv=none; d=google.com; s=arc-20160816; b=rnZa3EGQLjZvSSPYXPxKu5N3CQCu3uYCjwULdM8eBHOzGe4+FD9g0JGiCApWYl+twA +S/jq+JdLcL9xJFGvCTnW5yyG51KIkBRm7wSKeWBUZT/Ta46h5d0JLGvtb/AIfaEo4K/ Ie+tfh5t3XoJK7in/imEDGvym8og0bCfPOwxmyyrS5J5VPGnUTM59kGUtZ/eqBHGASSH z1nMfqasIK9UNMCzlUvqY1SuErX2VfyAHh04ILoLdpbvW3izRkLLyZLSFjj7+A2+QXvh L9V0tlaKgHQ0QUx/7Nu6Cmfi/40ADQjsfO8BYSPrQbHMYjTxCLQE9GYrcIRzxJyT1TR4 PLIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=oZHKLnNhfOD1TR9nUEnOw2v6BtOs+0YTR6k9PM6W1Ns=; b=WlRRvUx8MYNOyP1eg5MicfnZv3wW82GO2b0mV31uUAKJcdlL92ThwcBdWSsEdxa+by fMupWfEV7Xxv0sGSRFjEOs036GpZxs8BMwdGA4C2WQJhuKtPi+VNHaPWp1d3Sugszex9 1lLI0JQoYshAsYl6/P6QYhKEgcS+b4GImDe5G/YfPMtcOJ5mAQckOEF+5QfKlYM5IqDy 72Bq86izJjFNSG4E8w2BHcQZ8PId4IgxkI0aQjLJOFY3IbgqIPfSUSJl6wOq/78TfLqx CMSoO2XMAzuAd8ji8sL8E1D/l4Gtp+Kkf6khSdHAc5mjO0BCcN0fnY52kueLsFvDP/xM abgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b1NSEzoB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2-v6si2476813pgo.289.2018.05.11.04.12.05; Fri, 11 May 2018 04:12:05 -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=@linaro.org header.s=google header.b=b1NSEzoB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753641AbeEKLMD (ORCPT + 29 others); Fri, 11 May 2018 07:12:03 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40350 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416AbeEKLJf (ORCPT ); Fri, 11 May 2018 07:09:35 -0400 Received: by mail-wm0-f68.google.com with SMTP id j5-v6so2500850wme.5 for ; Fri, 11 May 2018 04:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oZHKLnNhfOD1TR9nUEnOw2v6BtOs+0YTR6k9PM6W1Ns=; b=b1NSEzoBeT0marUyGE6mxnLF2nlYTeJQQHiUoeYEm5TjuTaZ7lzNyigaIaVrBOQ4A9 nG0PPv9sJwzxdXO1/e0crwwfIk8gsuo/UZbRz51o1HVJA2Rfc8efo6Tqm2qnX1xFdOQ3 +63WusHK06Q9kmqTvLiYyCYefJE6R5ibgD0b8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oZHKLnNhfOD1TR9nUEnOw2v6BtOs+0YTR6k9PM6W1Ns=; b=PUC1HNKUIrsvoA61aD1T1TVvQLJP+3g9yKtckhIDNl/ur6gyEpuw913V9hCkZf1wQx islPuWZ8BFkNRACPh7lRnK0ol2SwfdEf5yYsMNElkcyFq4Oz//031uKOyKnPcgWSeWAF ts9dnrK/TjPAK+uY2aJGIsG8q9QxJFBAYQy1rkZSKhIINEM5N0QVkqJap+5l+/kDYpIV R+0WEACiKc7UvjRVevxqWHdK/ikVNaD+khleXl3JqsFQkpg/ILS7hX8kXxmn7RlJrwk9 uYHbUIL01wrZHxg39Fmf886uvyYX8mkfjB8VyhTW/zdDq1XwvvCH6QjX5iIF3EpxDJPl gIDw== X-Gm-Message-State: ALKqPwdaIS4haZn1wZlwbvbtivYFQa2Sg7g29PiCWsy/htdiNPOaKCaq F1lkEvz2nwGrX+A02MrRgeJcLA== X-Received: by 2002:a1c:84cb:: with SMTP id g194-v6mr1804820wmd.8.1526036974244; Fri, 11 May 2018 04:09:34 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id a129-v6sm714047wme.34.2018.05.11.04.09.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 04:09:33 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Jerome Brunet Subject: [PATCH 5/8] nvmem: meson-efuse: simplify read callback Date: Fri, 11 May 2018 12:07:00 +0100 Message-Id: <20180511110703.4924-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> References: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerome Brunet Most of the code and variables in the read callback is not necessary. Keep only what is required. Signed-off-by: Jerome Brunet Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/meson-efuse.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) -- 2.16.2 diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c index 2df9b0094f45..4623249dfd87 100644 --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -24,15 +24,8 @@ static int meson_efuse_read(void *context, unsigned int offset, void *val, size_t bytes) { - u8 *buf = val; - int ret; - - ret = meson_sm_call_read(buf, bytes, SM_EFUSE_READ, offset, - bytes, 0, 0, 0); - if (ret < 0) - return ret; - - return 0; + return meson_sm_call_read((u8 *)val, bytes, SM_EFUSE_READ, offset, + bytes, 0, 0, 0); } static const struct of_device_id meson_efuse_match[] = { From patchwork Fri May 11 11:07:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 135526 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp721731lji; Fri, 11 May 2018 04:11:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrnxar5iVeygEDKgYMm4QZxpxlkJ0vcCiRUcuE3DlGaOkwgqMe/GrWOzCgBLvV4R9tQ7K9V X-Received: by 2002:a62:f909:: with SMTP id o9-v6mr5077861pfh.256.1526037111246; Fri, 11 May 2018 04:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526037111; cv=none; d=google.com; s=arc-20160816; b=eJjux4o+hDZVJVs0Ayk+FTS+c9plp/WEF+sZ/IYLRS7+tLVB3ZUPKOaK12U+59bRsA o3oMjPaa2OZ6CTqWCjRUh0JPLiPMQGd6Eyg8BZ2RxcfirWUnrLpfvI1OpfNY4kuQA1IJ eKUPQ4+O0sUQ5QYrTNHUsGfeG+BwtKUtQc3waRRB/YYC57qyN1Ziht8Xsov9mllt4Amj fkMD1wvlPClM1yAH+F/l6N5d3aTk/g2ehSacGj4RwFoN9AoM0nZxWAmXGHxlIR+saH2i cfvnQiqqDSteki9bv9hkO8gljNG3NRamREKV5daqWLx3Z7Y8F233+pzqtlUKJzT1ZtQ9 rkfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=knlOZa3kWejwQyXaSPUlYA5Ylqs5mOu7wvB+yHzU8sg=; b=vK0oYHew3ZX96i92llgFJZ/bKksBk6VIvG7JRQdDds1J7eJpvDq4uiAuDwwhiaMkbZ kNjFhpabNo34y4n5KQNzR3JvHCv5mJSarnZj1BInmVTbFrHDwbuwlxnilIAvG1tZB4uM XDLbiE4SIU93SqMsdTa+hpLzw96/SnqOVZXqHrXcKiRlhUx5EsrEOKi2dgK4GpPpCUTl If6s3xhFNZLpjPsH4gcRGPTM9gKbiXv/q6C49O5lVZfbkPWbbohoAC7Si7EY1AvnfS2W /SYY08bt/TRgsS+xNKYnNcpX2wHWGcYApfL9iCvQfaS8zzP0Ji27vgSbnCb6Jv0g057r IlrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hxTlPOpr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2-v6si2476813pgo.289.2018.05.11.04.11.50; Fri, 11 May 2018 04:11: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=@linaro.org header.s=google header.b=hxTlPOpr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753632AbeEKLLr (ORCPT + 29 others); Fri, 11 May 2018 07:11:47 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35782 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753428AbeEKLJg (ORCPT ); Fri, 11 May 2018 07:09:36 -0400 Received: by mail-wm0-f67.google.com with SMTP id o78-v6so2532856wmg.0 for ; Fri, 11 May 2018 04:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=knlOZa3kWejwQyXaSPUlYA5Ylqs5mOu7wvB+yHzU8sg=; b=hxTlPOprUWX/s/vO1eReVCVgZtjHuYRsKPxEbsDeItre2yo8mGtL+EuksEFF8rHRE2 txa/LpqA/bjWAp96wWtYPpKlpTG50HaydRRz1Lzq3ajdUk06M90QeKvYmAVJNdf+joI2 s3GEUiZrS3NvD9iif6Js3Yz4DjJKlkD3pcor0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=knlOZa3kWejwQyXaSPUlYA5Ylqs5mOu7wvB+yHzU8sg=; b=jk8vcGzDKtJRoWy6dFpSAPYQDRT/9rQuGEIsnX7jz/FRdzikrlsaoWENBVJ5wJLGqg ntHctxVyLDkh31ha/9DJOYRH0jM6ZsJWoCWPgMeT9eVWpIOLC9qPgFBZ+VnImLCYMfIZ iTI/v41uDii0t2zb3yXkCZlPD7pnCDTIJN2YOc3+VhI/B59DxJ+eH00wwixgrHrf13uy A2W70gPpzUCuDHhf558WOHAuWudWnwD+54g8+D7TgEUorwyXrm3etBJ3tsJ1RPWfgBAF +DcJ2SJBUXwETAVRcRD1U2rimDD1t+edf1Ja7e5V+YqrWajVglSgOc8WnUIkNc+4d7o4 nAxQ== X-Gm-Message-State: ALKqPwdtbQh6zfaRon/Yw/R9xPDSuGNpeJArmLZVvw1Aduln1N82lVZ/ 4p2TOZ5l8DO0B5qAcLXCalKhfA== X-Received: by 2002:a1c:7d42:: with SMTP id y63-v6mr1695943wmc.121.1526036975092; Fri, 11 May 2018 04:09:35 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id a129-v6sm714047wme.34.2018.05.11.04.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 04:09:34 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Jerome Brunet Subject: [PATCH 6/8] nvmem: meson-efuse: add write support Date: Fri, 11 May 2018 12:07:01 +0100 Message-Id: <20180511110703.4924-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> References: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jerome Brunet Add write support to the meson-gx efuse driver. Beware, this efuse is one time programmable ! Reviewed-by: Kevin Hilman Signed-off-by: Jerome Brunet Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/meson-efuse.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.16.2 diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c index 4623249dfd87..d769840d1e18 100644 --- a/drivers/nvmem/meson-efuse.c +++ b/drivers/nvmem/meson-efuse.c @@ -28,6 +28,13 @@ static int meson_efuse_read(void *context, unsigned int offset, bytes, 0, 0, 0); } +static int meson_efuse_write(void *context, unsigned int offset, + void *val, size_t bytes) +{ + return meson_sm_call_write((u8 *)val, bytes, SM_EFUSE_WRITE, offset, + bytes, 0, 0, 0); +} + static const struct of_device_id meson_efuse_match[] = { { .compatible = "amlogic,meson-gxbb-efuse", }, { /* sentinel */ }, @@ -52,8 +59,8 @@ static int meson_efuse_probe(struct platform_device *pdev) econfig->name = dev_name(dev); econfig->stride = 1; econfig->word_size = 1; - econfig->read_only = true; econfig->reg_read = meson_efuse_read; + econfig->reg_write = meson_efuse_write; econfig->size = size; nvmem = devm_nvmem_register(&pdev->dev, econfig); From patchwork Fri May 11 11:07:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 135525 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp720961lji; Fri, 11 May 2018 04:11:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQalXVOwHKMMtu7kzqCbmn+UPPEn2sH/avRi/iVzoViiOdyl0YN46/FKq4CiLvsj1UvKPf X-Received: by 2002:a65:47cb:: with SMTP id f11-v6mr4126099pgs.235.1526037069612; Fri, 11 May 2018 04:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526037069; cv=none; d=google.com; s=arc-20160816; b=mq2yWuSAew0WC3fHUChuDhmNS/xyByNnkd5yO5V5feiPwDc19WkO2nUr7IFgFzgFmf pwh4mU9OTpSeGiVfKKKpkK4V09BbR06+DznuGsbEf1ljuHm9zdvj/06+c8PmueHeUXXR DBVg7F1gskHtal38Cbi3UbPMPdkLZ46kSGId3G5plmmda+89da+LnOPj0Dxif8ZIpjHb k6PJNFg+oEPXxCMCVcfU0RA9UvhKWBoRLAbPb2K4C58OfO9YuiTIIPne8L57y6VEmyph 0xZgENRj3PNqnrmzFV7510iS/WjlcYdaaRKOa/DXVsNPlxtXY+LSiV6yy6lShvryVzwx gl/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=eDLacnyz2Sx4d3x3swArJATYhMnSB+WxXyrGozFdY0o=; b=CghSQJhUXP8kBV7LSYQFTyU1GaWSchCGA3wTTkFdwhFY0Kn21BhrenG0E/Yo2I5A/1 eyd2yb2K82sHm+LmWpb/irLYsddV2/f6ELN0RqvJFiMbFpjxbmlBpUBUE/R2UlgbbFs+ pS3KoVuE+yDivwY/25YwXjzQson/+FZdKNGz1Ggqn4iZezngYRscZiuWdPvWEBDXGOLG OFhP0jGAxGR80kntn+2UGd9L05mtR6iLnSvMPNNRN6P6U2pl8BuMLZxOFxxzzAiHeBZQ sGUnGdv7zCDbjKfb9NiOBBRriLteyd3B9UxyQFlnmDDVWkjIpheVMKowvNFmS2bOcLl3 skgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LM86dHfH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2-v6si3116213plk.433.2018.05.11.04.11.09; Fri, 11 May 2018 04:11:09 -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=@linaro.org header.s=google header.b=LM86dHfH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753617AbeEKLLH (ORCPT + 29 others); Fri, 11 May 2018 07:11:07 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35591 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753433AbeEKLJh (ORCPT ); Fri, 11 May 2018 07:09:37 -0400 Received: by mail-wr0-f193.google.com with SMTP id i14-v6so4964960wre.2 for ; Fri, 11 May 2018 04:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eDLacnyz2Sx4d3x3swArJATYhMnSB+WxXyrGozFdY0o=; b=LM86dHfHS+kkNph82xvEkk3LTqTmTUkO8H/ZN9gEipLo8gSMB/C6G2MH2c7T2GL6MG r+IIaxO9d8ZH3agZNRL1IsUazdZ89G5In+UnsuvYjfEPa8Iue6dkRBZ2rNICrqOvwKy3 cKCApD5AeRjo6+BkKr3HuS4lKjydR8Ur36v4M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eDLacnyz2Sx4d3x3swArJATYhMnSB+WxXyrGozFdY0o=; b=s3C+IygyDaKuMw1AOzJSesLNEUfRWVnJ8HIOHN4VGv1KPkbTRwjQeiszqqD8lM69D1 50HJun8abm/5ZhK2Me3ZbWOzFI9kPHxuyRU6Yr+JFNzX2Bwz3El9kzrp8ZhdT3LICHxE Z7QokyZKqNb2XWcTJfMZp8GDNBMfJEDPC/1si+7bkpiL+MDejTfRwv7LBY+5udv0amH2 jF9EnO4dWp1U7rQBW7eY/PEutX/6reMiCWlKUr0GtGP7KUTyEVE1P5uQ5HWvPfaVOerr MPbdkLptDKpExXnsu31mSnYb6kmMZROSJvg23Rc2PUmC/tahJBx+/qNrm6Rzpd/bu6kG idPw== X-Gm-Message-State: ALKqPwcWtm3WMdcHkS4oum6CKLr2YbvMchLCSceedqWWqNDYmmu3aNrZ m6vcQUYio2SHT8PmymmB1J/GqJF8kFk= X-Received: by 2002:adf:a805:: with SMTP id l5-v6mr3894340wrc.97.1526036975974; Fri, 11 May 2018 04:09:35 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id a129-v6sm714047wme.34.2018.05.11.04.09.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 04:09:35 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org Subject: [PATCH 7/8] nvmem: core: describe add missing dev function parameter Date: Fri, 11 May 2018 12:07:02 +0100 Message-Id: <20180511110703.4924-8-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> References: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document dev parameter which not described in devm_nvmem_unregister and devm_nvmem_register functions. Fix below warnings when kernel is compiled with W=1 drivers/nvmem/core.c:579: warning: Function parameter or member 'dev' not described in 'devm_nvmem_register' nvmem/core.c:615: warning: Function parameter or member 'dev' not described in 'devm_nvmem_unregister' Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.16.2 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index b1c95ef78544..36361044ddbe 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -569,6 +569,7 @@ static void devm_nvmem_release(struct device *dev, void *res) * nvmem_config. * Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem * + * @dev: Device that uses the nvmem device. * @config: nvmem device configuration with which nvmem device is created. * * Return: Will be an ERR_PTR() on error or a valid pointer to nvmem_device @@ -607,6 +608,7 @@ static int devm_nvmem_match(struct device *dev, void *res, void *data) * devm_nvmem_unregister() - Unregister previously registered managed nvmem * device. * + * @dev: Device that uses the nvmem device. * @nvmem: Pointer to previously registered nvmem device. * * Return: Will be an negative on error or a zero on success. From patchwork Fri May 11 11:07:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 135524 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp720567lji; Fri, 11 May 2018 04:10:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZobTw8EcoGEg07VwlnpWnfw8/cflaUSBqF8FN7lHfPuTme+tk0EzUXh/oLXO9fbi+lh1Sci X-Received: by 2002:a65:6085:: with SMTP id t5-v6mr1951646pgu.362.1526037049478; Fri, 11 May 2018 04:10:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526037049; cv=none; d=google.com; s=arc-20160816; b=RftRrNzrwRKhU17Xamfs7qEM6cgAKOY4d5z/4xZhMPrlM8zbIWRYlGVI6MdbIjDqrU pTpOeu1jnOqQbTZWvS7ZOWlYcaGAc3ink2BRnSJ/ba0pxpt4fDwR4jDOtv7xC6Uguupt OxdHzXQyf7ocwy6mfBygKB45iOngvMgSDUJWIjiFIl4x0VeXnA1AD0AjGPCOixVEXs+x 5hGAIcnjKPAiRSCFyTQVIxUDhnwGmaemPuIAEoNIju6gZNoLl7rNF5AavdIZRFqe77Y/ XnYiMCGPGIkwZMZE8kdDUepKUV9IJsyz8CnWLT5gokkXdnhe5wPyFUvpi4Upu/9S6h/n j5cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=w5TjQwKiVwpDnrp/KCzD6gMlzqCUY8K4AVpRvmhKkF0=; b=LCSEHJSV0tlGxOFWiiuGpcvG0eyJ+7b6oXuESSBNZ+ChzqVlPyAfK1irRg6XCRb2Ks YheAONeVMbIhO++jmvKDkUPN4zG7xIU+UCBYqPRSViopKRS6fiTf5dkq8cajoNAWg4dy r+hfggw174+Kstr79mcE2Lkuq0zfR4Bn+8VSVy6MBNPSaSUQ9f7sqmph7DUgvWnDaFo3 siW23hqpcfG5Tk7GwUswup6EIsnCE28pLAeJSvRvQV/2BWHh369M4+m045ymIXBiiZEU NOqz2qDXg8/baYaf4cIquUaezntU2epLrqk/wARJjs2W7+Df34Z6UiC6N7kaLrMDXmtn EgJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iYYkLbiT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e11-v6si2256362pgs.476.2018.05.11.04.10.49; Fri, 11 May 2018 04:10:49 -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=@linaro.org header.s=google header.b=iYYkLbiT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753563AbeEKLKq (ORCPT + 29 others); Fri, 11 May 2018 07:10:46 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:38869 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753451AbeEKLJi (ORCPT ); Fri, 11 May 2018 07:09:38 -0400 Received: by mail-wr0-f193.google.com with SMTP id 94-v6so4949961wrf.5 for ; Fri, 11 May 2018 04:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w5TjQwKiVwpDnrp/KCzD6gMlzqCUY8K4AVpRvmhKkF0=; b=iYYkLbiTjpCBDnWUzymSo2hKmkC/6pI24txDlzP2rcTJYKSXSglGKJzL1DzcsQMKEl Lv1h4JhMzHV8SPUHzAf923ADk5MnimPxMAWbg1Am3f3P9kgxAW9fRJy10Bh+xesakBLE o3FmudmxB0SmjAwMHwpMiBygc48cxl0//tXuM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w5TjQwKiVwpDnrp/KCzD6gMlzqCUY8K4AVpRvmhKkF0=; b=cf6aXLl6cGOY9mG9UI7hIVMoZtf9s9l3CSFkXXNM0NnXQ5e8K56ctd8dyesD+13Y3K icP1UowOC1MYZ72Ip1ANpTF8hJ06eENb6IrRF6b4HIFNqr6+kqC6BrVxr0BKjXw72c7y hogTdriK8r20szFvRbBEHCayuhZZR4mFc28WeySfWGTj20T77abRnhueq1j6Rq3ppG7m Mv6jd22ExScOovu847EveSf/vnIvcak/IeadmO1kN8opnUnRDP9qrvFmTDBmkG6lYTRn saIGSGKGhDZ7rEBzJtzSxnqpuXvNvULPQe1NORstmkwT9db9itBLI1zSqAjcV/+vZ/c+ 8C0Q== X-Gm-Message-State: ALKqPwfc4HEVizE4hoMCoCPCSz7vFaAep5GH+4e2hRSq8vBRdKRD6Bd5 cTjWugcIku8tuSC5OTKzGmOM7w== X-Received: by 2002:adf:a98f:: with SMTP id b15-v6mr4026533wrd.48.1526036976880; Fri, 11 May 2018 04:09:36 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id a129-v6sm714047wme.34.2018.05.11.04.09.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 May 2018 04:09:36 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, srinivas.kandagatla@linaro.org, Mathieu Malaterre Subject: [PATCH 8/8] nvmem: properly handle returned value nvmem_reg_read Date: Fri, 11 May 2018 12:07:03 +0100 Message-Id: <20180511110703.4924-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> References: <20180511110703.4924-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathieu Malaterre Function nvmem_reg_read can return a non zero value indicating an error. This returned value must be read and error propagated to nvmem_cell_prepare_write_buffer. Silence the following gcc warning (W=1): drivers/nvmem/core.c:1093:9: warning: variable 'rc' set but not used [-Wunused-but-set-variable] Signed-off-by: Mathieu Malaterre Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.16.2 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 36361044ddbe..b5b0cdc21d01 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1119,6 +1119,8 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell, /* setup the first byte with lsb bits from nvmem */ rc = nvmem_reg_read(nvmem, cell->offset, &v, 1); + if (rc) + goto err; *b++ |= GENMASK(bit_offset - 1, 0) & v; /* setup rest of the byte if any */ @@ -1137,11 +1139,16 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell, /* setup the last byte with msb bits from nvmem */ rc = nvmem_reg_read(nvmem, cell->offset + cell->bytes - 1, &v, 1); + if (rc) + goto err; *p |= GENMASK(7, (nbits + bit_offset) % BITS_PER_BYTE) & v; } return buf; +err: + kfree(buf); + return ERR_PTR(rc); } /**