Re: [PATCH v8 2/9] nvmem: Add a simple NVMEM framework for consumers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Srinivas,

> Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx> hat am 20. Juli 2015 um
> 16:43 geschrieben:
>
>
> This patch adds just consumers part of the framework just to enable easy
> review.
>
> Up until now, nvmem drivers were stored in drivers/misc, where they all
> had to duplicate pretty much the same code to register a sysfs file,
> allow in-kernel users to access the content of the devices they were
> driving, etc.
>
> This was also a problem as far as other in-kernel users were involved,
> since the solutions used were pretty much different from on driver to
> another, there was a rather big abstraction leak.
>
> This introduction of this framework aims at solving this. It also
> introduces DT representation for consumer devices to go get the data they
> require (MAC Addresses, SoC/Revision ID, part numbers, and so on) from
> the nvmems.
>
> Having regmap interface to this framework would give much better
> abstraction for nvmems on different buses.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@xxxxxxxxxxxxxxxxxx>
> [Maxime Ripard: intial version of the framework]
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx>
> ---
> drivers/nvmem/core.c | 415 +++++++++++++++++++++++++++++++++++++++++
> include/linux/nvmem-consumer.h | 61 ++++++
> 2 files changed, 476 insertions(+)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index bde5528..de14c36 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> [...]
> +struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
> + const char *name)
> +{
> + struct device_node *cell_np, *nvmem_np;
> + struct nvmem_cell *cell;
> + struct nvmem_device *nvmem;
> + const __be32 *addr;
> + int rval, len, index;
> +
> + index = of_property_match_string(np, "nvmem-cell-names", name);
> +
> + cell_np = of_parse_phandle(np, "nvmem-cells", index);
> + if (!cell_np)
> + return ERR_PTR(-EINVAL);
> +
> + nvmem_np = of_get_next_parent(cell_np);
> + if (!nvmem_np)
> + return ERR_PTR(-EINVAL);
> +
> + nvmem = __nvmem_device_get(nvmem_np, NULL, NULL);
> + if (IS_ERR(nvmem))
> + return ERR_CAST(nvmem);
> +
> + addr = of_get_property(cell_np, "reg", &len);
> + if (!addr || (len < 2 * sizeof(int))) {

I'm not sure, but shouldn't be sizeof(u32) more portable?

> [...]
> +
> + addr = of_get_property(cell_np, "bits", &len);
> + if (addr && len == (2 * sizeof(int))) {

dito

Regards
Stefan
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux