From: srinivas.kandagatla@linaro.org (Srinivas Kandagatla)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 1/9] nvmem: Add a simple NVMEM framework for nvmem providers
Date: Wed, 24 Jun 2015 10:54:30 +0100 [thread overview]
Message-ID: <558A7E56.9060006@linaro.org> (raw)
In-Reply-To: <982684639.251832.1435090259373.JavaMail.open-xchange@oxbsltgw00.schlund.de>
On 23/06/15 21:10, Stefan Wahren wrote:
> Hi Srinivas,
>
> sorry for the messed up indention.
>
NP,
>> + */
>> +
>> +#include <linux/device.h>
>> +#include <linux/nvmem-provider.h>
>> +#include <linux/export.h>
>> +#include <linux/fs.h>
>> +#include <linux/idr.h>
>> +#include <linux/init.h>
>> +#include <linux/regmap.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/slab.h>
>
> Sorting alphabetically would by nice
>
Good Idea.
>> + [...]
>> +/**
>> + * 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.
I will give it a try.
thanks,
srini
>
> Stefan
>
next prev parent reply other threads:[~2015-06-24 9:54 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 23:07 [PATCH v6 0/9] Add simple NVMEM Framework via regmap Srinivas Kandagatla
2015-06-22 23:08 ` [PATCH v6 1/9] nvmem: Add a simple NVMEM framework for nvmem providers Srinivas Kandagatla
2015-06-23 4:52 ` Joe Perches
2015-06-23 9:26 ` Pantelis Antoniou
2015-06-24 9:56 ` Srinivas Kandagatla
2015-06-23 20:10 ` Stefan Wahren
2015-06-24 9:54 ` Srinivas Kandagatla [this message]
2015-06-22 23:08 ` [PATCH v6 2/9] nvmem: Add a simple NVMEM framework for consumers Srinivas Kandagatla
2015-06-23 20:16 ` Stefan Wahren
2015-06-24 9:53 ` Srinivas Kandagatla
2015-06-22 23:08 ` [PATCH v6 3/9] nvmem: Add nvmem_device based consumer apis Srinivas Kandagatla
2015-06-23 20:28 ` Stefan Wahren
2015-06-24 9:52 ` Srinivas Kandagatla
2015-06-22 23:08 ` [PATCH v6 4/9] nvmem: Add bindings for simple nvmem framework Srinivas Kandagatla
2015-06-23 20:35 ` Stefan Wahren
2015-06-24 9:51 ` Srinivas Kandagatla
2015-06-22 23:09 ` [PATCH v6 5/9] Documentation: nvmem: add nvmem api level and how-to doc Srinivas Kandagatla
2015-06-22 23:09 ` [PATCH v6 6/9] nvmem: qfprom: Add Qualcomm QFPROM support Srinivas Kandagatla
2015-06-24 22:07 ` Stephen Boyd
2015-06-22 23:09 ` [PATCH v6 7/9] nvmem: qfprom: Add bindings for qfprom Srinivas Kandagatla
2015-06-23 9:25 ` Rajendra Nayak
2015-06-24 9:49 ` Srinivas Kandagatla
2015-06-22 23:09 ` [PATCH v6 8/9] nvmem: sunxi: Move the SID driver to the nvmem framework Srinivas Kandagatla
2015-06-23 20:44 ` Stefan Wahren
2015-06-24 9:48 ` Srinivas Kandagatla
2015-06-22 23:15 ` [PATCH v6 9/9] nvmem: Add to MAINTAINERS for " Srinivas Kandagatla
2015-06-23 19:47 ` [PATCH v6 0/9] Add simple NVMEM Framework via regmap Stefan Wahren
2015-06-24 5:54 ` Sanchayan Maity
2015-06-24 9:46 ` Srinivas Kandagatla
2015-06-24 12:30 ` Stefan Wahren
2015-06-24 13:03 ` Srinivas Kandagatla
2015-06-24 17:47 ` Stefan Wahren
2015-06-24 18:50 ` Srinivas Kandagatla
2015-06-30 17:47 ` Stefan Wahren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=558A7E56.9060006@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).