Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933252AbbFWULn (ORCPT ); Tue, 23 Jun 2015 16:11:43 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:61970 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754766AbbFWULf (ORCPT ); Tue, 23 Jun 2015 16:11:35 -0400 Date: Tue, 23 Jun 2015 22:10:59 +0200 (CEST) From: Stefan Wahren Reply-To: Stefan Wahren To: Srinivas Kandagatla , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org Cc: wxt@rock-chips.com, linux-api@vger.kernel.org, Kumar Gala , Rob Herring , sboyd@codeaurora.org, arnd@arndb.de, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, mporter@konsulko.com, Maxime Ripard , pantelis.antoniou@konsulko.com, devicetree@vger.kernel.org, Mark Brown Message-ID: <982684639.251832.1435090259373.JavaMail.open-xchange@oxbsltgw00.schlund.de> In-Reply-To: <1435014507-26181-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1435014459-26138-1-git-send-email-srinivas.kandagatla@linaro.org> <1435014507-26181-1-git-send-email-srinivas.kandagatla@linaro.org> Subject: Re: [PATCH v6 1/9] nvmem: Add a simple NVMEM framework for nvmem providers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.6.2-Rev18 X-Originating-Client: com.openexchange.ox.gui.dhtml X-Provags-ID: V03:K0:0DjL5z08ZM03Fk5kEBagYLBqtHcZUmBO300BV6uk3bU7fU+VME4 1YrlQMn/6WRgJdVmdRWxG1YNtggT5LezsulypF3ZEYP10BKeT9uRn8jL9clh7fovABdbKIp CRRY+cfoP7TNQiPTy0rP1Bsa/yB98QdV99+z5eAJMGmcPyZpbf4/QSxCz1hvmeqBcP8ag// oTiKyxcCKt7kvhpHvIfIg== X-UI-Out-Filterresults: notjunk:1;V01:K0:zPLU3T84H9Y=:Vs+wfSJuoKzg+64/W3B7le Y7/YEXkXerpISDluzj9SSE+imw4X1DKldM3tqvkx+my/FnT+OUzobPy5yQCt7Ga/yhwNlaWrv MmR55xk+SeA2XWAmr/popf3K6uScXNNdaeg44G+CvJsLl0tEJf7GFxJYUlzx2janqNhNruVkb qBBvgAQFYKBBH77SaFOUNgeSnO36otX6lYSnE6OFwiV5YX5Ubgu+O3zJYteyP6CGQLHWsNvui ExOZ2LKEEIw+f2DJuZtEZ2vlAqguthSP6ZAVMfIW/9Nw2MK/EBx2joWD+1ylWYuMPxdGfChUe U3zopazLqThEzFe9P761T6vdySS6eFiWW5EXzwwpsJJ0/gTQFNVNofLqaHU4sCpUj60pVTADX F7d0ebZuzjs3HGl9PzTdG1z//l2DTIBBoq3YI0YLphrrsvdXOwIVPKEPBXUg50Riqu/hdPcJp sGYIfD3KL+dZKevJPbyrJdHX8ctrSPyoz68MPXzR+USddR3LFhxy4wz37q7JoUGiouz5XE+cn oE20VCR9JeuRL5CfhT/Nf2oEXrTPQmaLaBkl5XIpMurtkgUv0FZhfEw8efzpxKKk9wq5lFUWn OiZ2d30FC6Q0Jw5Ta5vnHI57MKijl7APBnl5bSarDg80iM3cmqggkOQTjMXM7iFida5FytDpD C4B6CNIyffYBxiB9NEVvnN9Eo1hID3rTqXF/MkLHB8RMi9Q== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4389 Lines: 152 Hi Srinivas, sorry for the messed up indention. > Srinivas Kandagatla hat am 23. Juni 2015 um > 01:08 geschrieben: > > > [...] > --- /dev/null > +++ b/drivers/nvmem/Kconfig > @@ -0,0 +1,10 @@ > +menuconfig NVMEM > + tristate "NVMEM Support" > + select REGMAP > + help > + Support for NVMEM devices. > + > + This framework is designed to provide a generic interface to NVMEM > + from both the Linux Kernel and the userspace. In order to avoid confusion it would be good to write here what does NVMEM mean. > + > + If unsure, say no. > diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile > new file mode 100644 > index 0000000..6df2c69 > --- /dev/null > +++ b/drivers/nvmem/Makefile > @@ -0,0 +1,6 @@ > +# > +# Makefile for nvmem drivers. > +# > + > +obj-$(CONFIG_NVMEM) += nvmem_core.o > +nvmem_core-y := core.o > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > new file mode 100644 > index 0000000..17a826d > --- /dev/null > +++ b/drivers/nvmem/core.c > @@ -0,0 +1,398 @@ > +/* > + * nvmem framework core. > + * > + * Copyright (C) 2015 Srinivas Kandagatla > + * Copyright (C) 2013 Maxime Ripard > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 and > + * only version 2 as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include Sorting alphabetically would by nice > + [...] > +/** > + * nvmem_register() - Register a nvmem device for given nvmem_config. > + * Also creates an binary entry in /sys/class/nvmem/dev-name/nvmem > + * > + * @config: nvmem device configuration with which nvmem device is created. > + * > + * The return value will be an ERR_PTR() on error or a valid pointer > + * to nvmem_device. > + */ > + > +struct nvmem_device *nvmem_register(struct nvmem_config *config) > +{ > + struct nvmem_device *nvmem; > + struct regmap *rm; > + int rval; > + > + if (!config->dev) > + return ERR_PTR(-EINVAL); > + > + rm = dev_get_regmap(config->dev, NULL); > + if (!rm) { > + dev_err(config->dev, "Regmap not found\n"); > + return ERR_PTR(-EINVAL); > + } > + > + nvmem = kzalloc(sizeof(*nvmem), GFP_KERNEL); > + if (!nvmem) > + return ERR_PTR(-ENOMEM); > + > + nvmem->id = ida_simple_get(&nvmem_ida, 0, 0, GFP_KERNEL); > + if (nvmem->id < 0) { > + kfree(nvmem); > + return ERR_PTR(nvmem->id); > + } > + > + nvmem->regmap = rm; > + nvmem->owner = config->owner; > + nvmem->stride = regmap_get_reg_stride(rm); > + nvmem->word_size = regmap_get_val_bytes(rm); > + nvmem->size = regmap_get_max_register(rm) + nvmem->stride; > + nvmem->dev.class = &nvmem_class; > + nvmem->dev.parent = config->dev; > + nvmem->dev.of_node = config->dev->of_node; > + dev_set_name(&nvmem->dev, "%s%d", > + config->name ? : "nvmem", config->id); > + > + nvmem->read_only = nvmem->dev.of_node ? > + of_property_read_bool(nvmem->dev.of_node, > + "read-only") : > + config->read_only; > + > + device_initialize(&nvmem->dev); > + > + dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", > + dev_name(&nvmem->dev)); > + > + rval = device_add(&nvmem->dev); > + if (rval) { > + ida_simple_remove(&nvmem_ida, nvmem->id); > + kfree(nvmem); > + return ERR_PTR(rval); > + } > + > + /* update sysfs attributes */ > + if (nvmem->read_only) > + sysfs_update_group(&nvmem->dev.kobj, &nvmem_bin_ro_group); > + > + if (config->cells) > + nvmem_add_cells(nvmem, config); I think this would be a better place for the debug message from above. Additionally we could add the cell count and so on. Stefan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/