Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH v2 03/15] ASoC: qcom: qdsp6: Add common qdsp6 helper functions
From: Bjorn Andersson @ 2018-01-02  0:19 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20171214173402.19074-4-srinivas.kandagatla@linaro.org>

On Thu 14 Dec 09:33 PST 2017, srinivas.kandagatla at linaro.org wrote:
> +static inline int q6dsp_map_channels(u8 *ch_map, int ch)
> +{
> +	memset(ch_map, 0, PCM_FORMAT_MAX_NUM_CHANNEL);

This implies that ch_map is always an array of
PCM_FORMAT_MAX_NUM_CHANNEL elements. As such it would be better to
express this in the prototype; i.e u8 ch_map[PCM_FORMAT_MAX_NUM_CHANNEL]

> +
> +	if (ch == 1) {

This is a switch statement.

> +		ch_map[0] = PCM_CHANNEL_FC;
> +	} else if (ch == 2) {
[..]
> +struct adsp_err_code {
> +	int		lnx_err_code;

Indentation, and these could be given more succinct names.

> +	char	*adsp_err_str;
> +};
> +
> +static struct adsp_err_code adsp_err_code_info[ADSP_ERR_MAX+1] = {
> +	{ 0, ADSP_EOK_STR},
> +	{ -ENOTRECOVERABLE, ADSP_EFAILED_STR},
> +	{ -EINVAL, ADSP_EBADPARAM_STR},
> +	{ -ENOSYS, ADSP_EUNSUPPORTED_STR},
> +	{ -ENOPROTOOPT, ADSP_EVERSION_STR},
> +	{ -ENOTRECOVERABLE, ADSP_EUNEXPECTED_STR},
> +	{ -ENOTRECOVERABLE, ADSP_EPANIC_STR},
> +	{ -ENOSPC, ADSP_ENORESOURCE_STR},
> +	{ -EBADR, ADSP_EHANDLE_STR},
> +	{ -EALREADY, ADSP_EALREADY_STR},
> +	{ -EPERM, ADSP_ENOTREADY_STR},
> +	{ -EINPROGRESS, ADSP_EPENDING_STR},
> +	{ -EBUSY, ADSP_EBUSY_STR},
> +	{ -ECANCELED, ADSP_EABORTED_STR},
> +	{ -EAGAIN, ADSP_EPREEMPTED_STR},
> +	{ -EAGAIN, ADSP_ECONTINUE_STR},
> +	{ -EAGAIN, ADSP_EIMMEDIATE_STR},
> +	{ -EAGAIN, ADSP_ENOTIMPL_STR},
> +	{ -ENODATA, ADSP_ENEEDMORE_STR},
> +	{ -EADV, ADSP_ERR_MAX_STR},

This, element 0x13, is not listed among the defined errors. Is this a
placeholder?

How about making this even more descriptive by using the format

[ADSP_EBADPARAM] = { -EINVAL, ADSP_EBADPARAM_STR },

That way the mapping table is self-describing.

And you can use ARRAY_SIZE() instead of specifying the fixed size of
ADSP_ERR_MAX + 1...

> +	{ -ENOMEM, ADSP_ENOMEMORY_STR},
> +	{ -ENODEV, ADSP_ENOTEXIST_STR},
> +	{ -EADV, ADSP_ERR_MAX_STR},

"Advertise error"?

> +};
> +
> +static inline int adsp_err_get_lnx_err_code(u32 adsp_error)

Can this be made internal to some c-file? So that any third party deals
only with linux error codes?


How about renaming this q6dsp_errno()?

> +{
> +	if (adsp_error > ADSP_ERR_MAX)
> +		return adsp_err_code_info[ADSP_ERR_MAX].lnx_err_code;
> +	else
> +		return adsp_err_code_info[adsp_error].lnx_err_code;

I think this would look better if you assign a local variable and have a
single return. And just hard code the "invalid error code" errno, rather
than looking up ADSP_ERR_MAX in the list.

> +}
> +
> +static inline char *adsp_err_get_err_str(u32 adsp_error)

q6dsp_strerror(), to match strerror(3)?

> +{
> +	if (adsp_error > ADSP_ERR_MAX)
> +		return adsp_err_code_info[ADSP_ERR_MAX].adsp_err_str;
> +	else
> +		return adsp_err_code_info[adsp_error].adsp_err_str;

And I do think that, as with strerror, this should return a human
readable error, not the stringified define.

> +}


I'm puzzled to why these helper functions lives in a header file, at
least some aspects of this would better be hidden...

Regards,
Bjorn

^ permalink raw reply

* [RESEND PATCH v2 02/15] soc: qcom: add support to APR bus driver
From: Bjorn Andersson @ 2018-01-01 23:29 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20171214173402.19074-3-srinivas.kandagatla@linaro.org>

On Thu 14 Dec 09:33 PST 2017, srinivas.kandagatla at linaro.org wrote:

> From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> 
> This patch adds support toi APR bus (Asynchronous Packet Router) driver.
> ARP driver is made as a bus driver so that the apr devices can added removed
> more dynamically depending on the state of the services on the dsp.
> APR is used for communication between application processor and QDSP to
> use services on QDSP like Audio and others.
> 
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/soc/qcom/Kconfig        |   8 +
>  drivers/soc/qcom/Makefile       |   1 +
>  drivers/soc/qcom/apr.c          | 395 ++++++++++++++++++++++++++++++++++++++++
>  include/linux/mod_devicetable.h |  13 ++
>  include/linux/soc/qcom/apr.h    | 174 ++++++++++++++++++
>  5 files changed, 591 insertions(+)
>  create mode 100644 drivers/soc/qcom/apr.c
>  create mode 100644 include/linux/soc/qcom/apr.h
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index b81374bb6713..1daa39925dd4 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -97,4 +97,12 @@ config QCOM_WCNSS_CTRL
>  	  Client driver for the WCNSS_CTRL SMD channel, used to download nv
>  	  firmware to a newly booted WCNSS chip.
>  
> +config QCOM_APR
> +	tristate "Qualcomm APR Bus (Asynchronous Packet Router)"
> +	depends on (RPMSG_QCOM_SMD || RPMSG_QCOM_GLINK_RPM)

The actual dependency you have is RPMSG. Specifying the individual
transports here causes additional restrictions in how you can mix and
match modules vs builtin (e.g. glink being builtin to get regulators
early and smd built as a module forces apr to be built as a module)

PS, the glink config you're depending on is RPMSG_QCOM_GLINK_SMEM

> +	help
> +          Enable APR IPC protocol support between
> +          application processor and QDSP6. APR is
> +          used by audio driver to configure QDSP6
> +          ASM, ADM and AFE modules.
>  endmenu
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 40c56f67e94a..9daba7e6d20f 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -10,3 +10,4 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
>  obj-$(CONFIG_QCOM_SMP2P)	+= smp2p.o
>  obj-$(CONFIG_QCOM_SMSM)	+= smsm.o
>  obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
> +obj-$(CONFIG_QCOM_APR) += apr.o
> diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c
> new file mode 100644
> index 000000000000..c6f3aa7a375b
> --- /dev/null
> +++ b/drivers/soc/qcom/apr.c
> @@ -0,0 +1,395 @@
> +/* SPDX-License-Identifier: GPL-2.0
> +* Copyright (c) 2011-2016, The Linux Foundation
> +* Copyright (c) 2017, Linaro Limited
> +*/

For some tooling reason the SPDX line should be // commented, i.e this
should be:

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2011-2016, The Linux Foundation
 * Copyright (c) 2017, Linaro Limited
 */

> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/device.h>
> +#include <linux/spinlock.h>
> +#include <linux/list.h>
> +#include <linux/slab.h>
> +#include <linux/of_device.h>
> +#include <linux/soc/qcom/apr.h>
> +#include <linux/rpmsg.h>
> +#include <linux/of.h>
> +
> +struct apr_data {
> +	int (*get_data_src)(struct apr_hdr *hdr);
> +	int dest_id;
> +};
> +
> +struct apr {
> +	struct rpmsg_endpoint *ch;
> +	struct device *dev;
> +	spinlock_t svcs_lock;
> +	struct list_head svcs;
> +	int dest_id;
> +	const struct apr_data *data;
> +};
> +
> +/* Static CORE service on the ADSP */
> +static const struct apr_device_id core_svc_device_id =
> +		ADSP_AUDIO_APR_DEV("CORE", APR_SVC_ADSP_CORE);

How does this work out when we want to use APR for the modem services?

> +
> +/**
> + * apr_send_pkt() - Send a apr message from apr device
> + *
> + * @adev: Pointer to previously registered apr device.
> + * @buf: Pointer to buffer to send
> + *
> + * Return: Will be an negative on packet size on success.
> + */
> +int apr_send_pkt(struct apr_device *adev, uint32_t *buf)

So buf here is a struct apr_hdr followed by arbitrary data. Passing a
reference to an arbitrary chunk of data should be done with a void *.
But you could turn struct apr_hdr into struct apr_packet by adding a
flexible array member at the end of the struct and having this function
take that data type. This would make the prototype self-documenting.


I do, however, not fancy the asymmetry of the send/callback interface
exposed to the client. One takes the raw packet, as it sits in the
transport and the other creates an abstract representation of the same.

Can't you in the callback verify the data and then just pass the same
object up to the client?

> +{
> +	struct apr *apr = dev_get_drvdata(adev->dev.parent);
> +	struct apr_hdr *hdr;
> +	unsigned long flags;
> +	int ret;
> +
> +	spin_lock_irqsave(&adev->lock, flags);
> +
> +	hdr = (struct apr_hdr *)buf;
> +	hdr->src_domain = APR_DOMAIN_APPS;
> +	hdr->src_svc = adev->svc_id;
> +	hdr->dest_domain = adev->domain_id;
> +	hdr->dest_svc = adev->svc_id;
> +
> +	ret = rpmsg_send(apr->ch, buf, hdr->pkt_size);
> +	if (ret) {
> +		dev_err(&adev->dev, "Unable to send APR pkt %d\n",
> +			hdr->pkt_size);
> +	} else {
> +		ret = hdr->pkt_size;
> +	}
> +
> +	spin_unlock_irqrestore(&adev->lock, flags);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(apr_send_pkt);
> +
> +static void apr_dev_release(struct device *dev)
> +{
> +	struct apr_device *adev = to_apr_device(dev);
> +
> +	kfree(adev);
> +}
> +
> +static int qcom_rpmsg_q6_callback(struct rpmsg_device *rpdev, void *buf,
> +				  int len, void *priv, u32 addr)
> +{
> +	struct apr *apr = dev_get_drvdata(&rpdev->dev);
> +	struct apr_client_data data;
> +	struct apr_device *p, *c_svc = NULL;
> +	struct apr_driver *adrv = NULL;
> +	struct apr_hdr *hdr;
> +	uint16_t hdr_size;
> +	uint16_t msg_type;
> +	uint16_t ver;
> +	uint16_t src;
> +	uint16_t svc;
> +
> +	if (!buf || len <= APR_HDR_SIZE) {

rpmsg should never call you with buf = NULL, so no reason to check for
that.

> +		dev_err(apr->dev, "APR: Improper apr pkt received:%p %d\n",
> +			buf, len);
> +		return -EINVAL;
> +	}
> +
> +	hdr = buf;
> +	ver = APR_HDR_FIELD_VER(hdr->hdr_field);
> +	if (ver > APR_PKT_VER + 1)
> +		return -EINVAL;
> +
> +	hdr_size = APR_HDR_FIELD_SIZE_BYTES(hdr->hdr_field);
> +	if (hdr_size < APR_HDR_SIZE) {
> +		dev_err(apr->dev, "APR: Wrong hdr size:%d\n", hdr_size);
> +		return -EINVAL;
> +	}
> +
> +	if (hdr->pkt_size < APR_HDR_SIZE) {
> +		dev_err(apr->dev, "APR: Wrong paket size\n");
> +		return -EINVAL;
> +	}
> +
> +	msg_type = APR_HDR_FIELD_MT(hdr->hdr_field);
> +	if (msg_type >= APR_MSG_TYPE_MAX && msg_type != APR_BASIC_RSP_RESULT) {
> +		dev_err(apr->dev, "APR: Wrong message type: %d\n", msg_type);
> +		return -EINVAL;
> +	}
> +
> +	if (hdr->src_domain >= APR_DOMAIN_MAX ||
> +			hdr->dest_domain >= APR_DOMAIN_MAX ||
> +			hdr->src_svc >= APR_SVC_MAX ||
> +			hdr->dest_svc >= APR_SVC_MAX) {
> +		dev_err(apr->dev, "APR: Wrong APR header\n");
> +		return -EINVAL;
> +	}
> +
> +	svc = hdr->dest_svc;
> +	src = apr->data->get_data_src(hdr);

Couldn't we just use src_domain here instead of maintaining this mapping
table in the driver?

Also, looking at the send function, isn't this src just c_svc->svc_id?


> +	if (src == APR_DEST_MAX)
> +		return -EINVAL;
> +
> +	spin_lock(&apr->svcs_lock);
> +	list_for_each_entry(p, &apr->svcs, node) {
> +		if (svc == p->svc_id) {
> +			c_svc = p;
> +			if (c_svc->dev.driver)
> +				adrv = to_apr_driver(c_svc->dev.driver);
> +			break;
> +		}
> +	}

Keep your services in a idr, keyed by svc_id. This will make the search
O(log(n)), but more importantly it would replace this loop with a single
idr_find().

> +	spin_unlock(&apr->svcs_lock);
> +
> +	if (!adrv) {
> +		dev_err(apr->dev, "APR: service is not registered\n");
> +		return -EINVAL;
> +	}
> +
> +	data.payload_size = hdr->pkt_size - hdr_size;
> +	data.opcode = hdr->opcode;
> +	data.src = src;
> +	data.src_port = hdr->src_port;
> +	data.dest_port = hdr->dest_port;
> +	data.token = hdr->token;
> +	data.msg_type = msg_type;
> +
> +	if (data.payload_size > 0)
> +		data.payload = (char *)hdr + hdr_size;

Using buf + hdr_size probably makes even more sense, and saves you from
the typecast.

> +
> +	adrv->callback(c_svc, &data);
> +
> +	return 0;
> +}
> +
> +static const struct apr_device_id *apr_match(const struct apr_device_id *id,
> +					       const struct apr_device *adev)
> +{
> +	while (id->domain_id != 0 || id->svc_id != 0) {
> +		if (id->domain_id == adev->domain_id &&
> +		    id->svc_id == adev->svc_id &&
> +		    id->client_id == adev->client_id)

Is the client_id significant here? As far as I can tell it's a
identifier of the local "function". Are there multiple client drivers
that would "attach" to the same remote service?

> +			return id;
> +		id++;
> +	}
> +	return NULL;
> +}
> +
> +static int apr_device_match(struct device *dev, struct device_driver *drv)
> +{
> +	struct apr_device *adev = to_apr_device(dev);
> +	struct apr_driver *adrv = to_apr_driver(drv);
> +
> +	return !!apr_match(adrv->id_table, adev);

If this remain the only caller of apr_match() you could just inline the
loop here.

> +}
> +
> +static int apr_device_probe(struct device *dev)
> +{
> +	struct apr_device	*adev;
> +	struct apr_driver	*adrv;

You don't indent things elsewhere.

> +	int ret = 0;
> +
> +	adev = to_apr_device(dev);
> +	adrv = to_apr_driver(dev->driver);
> +
> +	ret = adrv->probe(adev);

Drop ret and just return adrv->probe()

> +
> +	return ret;
> +}
> +
> +static int apr_device_remove(struct device *dev)
> +{
> +	struct apr_device *adev = to_apr_device(dev);
> +	struct apr_driver *adrv;
> +	struct apr *apr = dev_get_drvdata(adev->dev.parent);
> +
> +	if (dev->driver) {
> +		adrv = to_apr_driver(dev->driver);
> +		if (adrv->remove)
> +			adrv->remove(adev);
> +		spin_lock(&apr->svcs_lock);
> +		list_del(&adev->node);
> +		spin_unlock(&apr->svcs_lock);
> +	}
> +
> +	return 0;
> +}
> +
> +struct bus_type aprbus_type = {
> +	.name		= "aprbus",
> +	.match		= apr_device_match,
> +	.probe		= apr_device_probe,
> +	.remove		= apr_device_remove,
> +};
> +EXPORT_SYMBOL_GPL(aprbus_type);
> +
> +/**
> + * apr_add_device() - Add a new apr device
> + *
> + * @dev: Pointer to apr device.
> + * @id: Pointer to apr device id to add.
> + *
> + * Return: Will be an negative on error or a zero on success.
> + */
> +int apr_add_device(struct device *dev, const struct apr_device_id *id)
> +{
> +	struct apr *apr = dev_get_drvdata(dev);

It's not obvious which dev this is, but it has to be the rpmsg device or
this would dereference the drvdata of the wrong type and things would be
very bad.

How about making this more explicit by just taking a struct apr * as
first argument, and then provide a helper for clients to acquire the
struct apr * from the parent dev, if this is needed.

> +	struct apr_device *adev = NULL;
> +
> +	if (!apr)
> +		return -EINVAL;
> +
> +	adev = kzalloc(sizeof(*adev), GFP_KERNEL);
> +	if (!adev)
> +		return -ENOMEM;
> +
> +	spin_lock_init(&adev->lock);
> +
> +	adev->svc_id = id->svc_id;
> +	adev->dest_id = apr->dest_id;
> +	adev->client_id = id->client_id;
> +	adev->domain_id = id->domain_id;

Wouldn't this always be the domain of the apr? (or we're adding a device
to the wrong apr)

> +	adev->version = id->svc_version;
> +
> +	adev->dev.bus = &aprbus_type;
> +	adev->dev.parent = dev;
> +	adev->dev.release = apr_dev_release;
> +	adev->dev.driver = NULL;
> +
> +	dev_set_name(&adev->dev, "apr:%s:%x:%x:%x", id->name, id->domain_id,
> +				 id->svc_id, id->client_id);
> +
> +	spin_lock(&apr->svcs_lock);
> +	list_add_tail(&adev->node, &apr->svcs);
> +	spin_unlock(&apr->svcs_lock);

This causes svcs to contain entries related to devices that has not been
matched and probed yet (e.g. implementation is in a kernel module not
loaded). I think you should move this to apr_device_probe().

> +
> +	return device_register(&adev->dev);
> +}
> +EXPORT_SYMBOL_GPL(apr_add_device);
> +
> +static int qcom_rpmsg_q6_probe(struct rpmsg_device *rpdev)
> +{
> +	struct device *dev = &rpdev->dev;
> +	struct apr *apr;
> +
> +	apr = devm_kzalloc(dev, sizeof(*apr), GFP_KERNEL);
> +	if (!apr)
> +		return -ENOMEM;
> +
> +	apr->data = of_device_get_match_data(dev);
> +	if (!apr->data)
> +		return -ENODEV;
> +
> +	apr->dest_id = apr->data->dest_id;
> +	dev_set_drvdata(dev, apr);
> +	apr->ch = rpdev->ept;
> +	apr->dev = dev;
> +	INIT_LIST_HEAD(&apr->svcs);
> +
> +	/* register core service */
> +	apr_add_device(dev, &core_svc_device_id);
> +
> +	return 0;
> +}
> +
> +static int apr_remove_device(struct device *dev, void *null)
> +{
> +	struct apr_device *adev = to_apr_device(dev);
> +
> +	device_unregister(&adev->dev);
> +
> +	return 0;
> +}
> +
> +static void qcom_rpmsg_q6_remove(struct rpmsg_device *rpdev)
> +{
> +	device_for_each_child(&rpdev->dev, NULL, apr_remove_device);
> +}
> +
> +static int apr_v2_get_data_src(struct apr_hdr *hdr)
> +{
> +	if (hdr->src_domain == APR_DOMAIN_MODEM)
> +		return APR_DEST_MODEM;
> +	else if (hdr->src_domain == APR_DOMAIN_ADSP)
> +		return APR_DEST_QDSP6;
> +
> +	return APR_DEST_MAX;

The idiomatic return value here would be -EINVAL.

> +}
> +
> +/*
> + * __apr_driver_register() - Client driver registration with aprbus
> + *
> + * @drv:Client driver to be associated with client-device.
> + * @owner: owning module/driver
> + *
> + * This API will register the client driver with the aprbus
> + * It is called from the driver's module-init function.
> + */
> +int __apr_driver_register(struct apr_driver *drv, struct module *owner)
> +{
> +	/* ID table is mandatory to match the devices to probe */
> +	if (!drv->id_table)
> +		return -EINVAL;
> +
> +	drv->driver.bus = &aprbus_type;
> +	drv->driver.owner = owner;
> +
> +	return driver_register(&drv->driver);
> +}
> +EXPORT_SYMBOL_GPL(__apr_driver_register);
> +
> +/*
> + * apr_driver_unregister() - Undo effect of apr_driver_register
> + *
> + * @drv: Client driver to be unregistered
> + */
> +void apr_driver_unregister(struct apr_driver *drv)
> +{
> +	driver_unregister(&drv->driver);
> +}
> +EXPORT_SYMBOL_GPL(apr_driver_unregister);
> +
> +static const struct apr_data apr_v2_data = {
> +	.get_data_src = apr_v2_get_data_src,
> +	.dest_id = APR_DEST_QDSP6,
> +};
> +
> +static const struct of_device_id qcom_rpmsg_q6_of_match[] = {
> +	{ .compatible = "qcom,apr-msm8996", .data = &apr_v2_data},

The dest_id of apr_v2_data and the use of "q6" in the name indicates
that this is the "msm8996 adsp apr", what's your plan to support other
apr remotes?

How about making the domain id a property of the apr in DT and then just
list the clients as nodes with svc_id, svc_version and client_id? You
can still match by device_id (compatible can be optional), but that
would allow you to describe either the adsp or modem apr link, of any
platform (of that apr version), with the same compatible.

> +	{}
> +};
> +
> +static struct rpmsg_driver qcom_rpmsg_q6_driver = {
> +	.probe = qcom_rpmsg_q6_probe,
> +	.remove = qcom_rpmsg_q6_remove,
> +	.callback = qcom_rpmsg_q6_callback,
> +	.drv = {
> +		.name = "qcom_rpmsg_q6",
> +		.owner = THIS_MODULE,

Drop the owner.

> +		.of_match_table = qcom_rpmsg_q6_of_match,
> +		},

Indentation.

> +};
> +
> +static int __init apr_init(void)
> +{
> +	int ret;
> +
> +	ret = register_rpmsg_driver(&qcom_rpmsg_q6_driver);
> +	if (!ret)
> +		return bus_register(&aprbus_type);

Register the bus first, then the rpmsg driver.

> +
> +	return ret;
> +}
> +
> +static void __exit apr_exit(void)
> +{
> +	bus_unregister(&aprbus_type);
> +	unregister_rpmsg_driver(&qcom_rpmsg_q6_driver);
> +}
> +
> +subsys_initcall(apr_init);
> +module_exit(apr_exit);
> +
> +MODULE_LICENSE("GPL v2");
> +MODULE_DESCRIPTION("Qualcomm APR Bus");
> diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
> index abb6dc2ebbf8..068d215c3be6 100644
> --- a/include/linux/mod_devicetable.h
> +++ b/include/linux/mod_devicetable.h
> @@ -452,6 +452,19 @@ struct spi_device_id {
>  	kernel_ulong_t driver_data;	/* Data private to the driver */
>  };
>  
> +

One newline is enough.

> +#define APR_NAME_SIZE	32
> +#define APR_MODULE_PREFIX "apr:"
> +
> +struct apr_device_id {
> +	char name[APR_NAME_SIZE];

Does this name has any meaning? As far as I can see we're matching on
the other parameters and use the name only to name the device.

> +	__u32 domain_id;
> +	__u32 svc_id;
> +	__u32 client_id;
> +	__u32 svc_version;
> +	kernel_ulong_t driver_data;	/* Data private to the driver */
> +};
> +
>  #define SPMI_NAME_SIZE	32
>  #define SPMI_MODULE_PREFIX "spmi:"
>  
> diff --git a/include/linux/soc/qcom/apr.h b/include/linux/soc/qcom/apr.h
> new file mode 100644
> index 000000000000..8620289c34ab
> --- /dev/null
> +++ b/include/linux/soc/qcom/apr.h
> @@ -0,0 +1,174 @@
> +/* SPDX-License-Identifier: GPL-2.0
> +* Copyright (c) 2011-2016, The Linux Foundation
> +* Copyright (c) 2017, Linaro Limited
> +*/
> +
> +#ifndef __APR_H_
> +#define __APR_H_
> +
> +#include <linux/spinlock.h>
> +#include <linux/device.h>
> +#include <linux/mod_devicetable.h>
> +/* APR Client IDs */
> +#define APR_CLIENT_AUDIO	0x0
> +#define APR_CLIENT_VOICE	0x1
> +#define APR_CLIENT_MAX		0x2
> +
> +#define APR_DL_SMD    0
> +#define APR_DL_MAX    1

Unused.

> +
> +#define APR_DEST_MODEM 0
> +#define APR_DEST_QDSP6 1
> +#define APR_DEST_MAX   2
> +#define APR_MAX_BUF   8192
> +
> +#define APR_HDR_LEN(hdr_len) ((hdr_len)/4)
> +#define APR_PKT_SIZE(hdr_len, payload_len) ((hdr_len) + (payload_len))
> +#define APR_HDR_FIELD(msg_type, hdr_len, ver)\
> +	(((msg_type & 0x3) << 8) | ((hdr_len & 0xF) << 4) | (ver & 0xF))
> +
> +#define APR_HDR_SIZE sizeof(struct apr_hdr)
> +#define APR_SEQ_CMD_HDR_FIELD APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, \
> +					    APR_HDR_LEN(APR_HDR_SIZE), \
> +					    APR_PKT_VER)

So for the tx path these macros are to be used by the client and for the
rx path they are to be used by the apr driver. Better make the api
symmetrical.

One possible path is to use an sk_buf for the tx-path and reserve space
for the header, then pass the abstract version of the packet and let the
apr driver fill out the header.

> +
> +/* Version */
> +#define APR_PKT_VER		0x0
> +
> +/* Command and Response Types */
> +#define APR_MSG_TYPE_EVENT	0x0
> +#define APR_MSG_TYPE_CMD_RSP	0x1
> +#define APR_MSG_TYPE_SEQ_CMD	0x2
> +#define APR_MSG_TYPE_NSEQ_CMD	0x3
> +#define APR_MSG_TYPE_MAX	0x04
> +
> +/* APR Basic Response Message */
> +#define APR_BASIC_RSP_RESULT 0x000110E8
> +#define APR_RSP_ACCEPTED     0x000100BE
> +
> +/* Domain IDs */
> +#define APR_DOMAIN_SIM	0x1
> +#define APR_DOMAIN_PC		0x2
> +#define APR_DOMAIN_MODEM	0x3
> +#define APR_DOMAIN_ADSP	0x4
> +#define APR_DOMAIN_APPS	0x5
> +#define APR_DOMAIN_MAX	0x6
> +
> +/* ADSP service IDs */
> +#define APR_SVC_TEST_CLIENT     0x2
> +#define APR_SVC_ADSP_CORE	0x3
> +#define APR_SVC_AFE		0x4
> +#define APR_SVC_VSM		0x5
> +#define APR_SVC_VPM		0x6
> +#define APR_SVC_ASM		0x7
> +#define APR_SVC_ADM		0x8
> +#define APR_SVC_ADSP_MVM	0x09
> +#define APR_SVC_ADSP_CVS	0x0A
> +#define APR_SVC_ADSP_CVP	0x0B
> +#define APR_SVC_USM		0x0C
> +#define APR_SVC_LSM		0x0D
> +#define APR_SVC_VIDC		0x16
> +#define APR_SVC_MAX		0x17
> +
> +/* Modem Service IDs */
> +#define APR_SVC_MVS		0x3
> +#define APR_SVC_MVM		0x4
> +#define APR_SVC_CVS		0x5
> +#define APR_SVC_CVP		0x6
> +#define APR_SVC_SRD		0x7
> +
> +/* APR Port IDs */
> +#define APR_MAX_PORTS		0x80
> +#define APR_NAME_MAX		0x40
> +#define RESET_EVENTS		0x000130D7
> +
> +/* hdr field Ver [0:3], Size [4:7], Message type [8:10] */
> +#define APR_HDR_FIELD_VER(h)		(h & 0x000F)
> +#define APR_HDR_FIELD_SIZE(h)		((h & 0x00F0) >> 4)
> +#define APR_HDR_FIELD_SIZE_BYTES(h)	(((h & 0x00F0) >> 4) * 4)
> +#define APR_HDR_FIELD_MT(h)		((h & 0x0300) >> 8)
> +
> +struct apr_hdr {
> +	uint16_t hdr_field;
> +	uint16_t pkt_size;
> +	uint8_t src_svc;
> +	uint8_t src_domain;
> +	uint16_t src_port;
> +	uint8_t dest_svc;
> +	uint8_t dest_domain;
> +	uint16_t dest_port;
> +	uint32_t token;
> +	uint32_t opcode;
> +};
> +
> +struct apr_client_data {

Perhaps name this apr_client_message or similar, to indicate that this
is not a per-client thing, but a description of a message/packet.

> +	uint16_t payload_size;
> +	uint16_t hdr_len;
> +	uint16_t msg_type;
> +	uint16_t src;
> +	uint16_t dest_svc;
> +	uint16_t src_port;
> +	uint16_t dest_port;
> +	uint32_t token;
> +	uint32_t opcode;
> +	void *payload;
> +};
> +

Regards,
Bjorn

^ permalink raw reply

* [PATCH v2 21/21] nvmem: bcm-ocotp: Do not use "&pdev->dev" explicitly
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

There's "dev" variable for this already. Use it.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/bcm-ocotp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nvmem/bcm-ocotp.c b/drivers/nvmem/bcm-ocotp.c
index 24c30fa475cc..4159b3f41d79 100644
--- a/drivers/nvmem/bcm-ocotp.c
+++ b/drivers/nvmem/bcm-ocotp.c
@@ -262,8 +262,7 @@ static int bcm_otpc_probe(struct platform_device *pdev)
 	else if (of_device_is_compatible(dev->of_node, "brcm,ocotp-v2"))
 		priv->map = &otp_map_v2;
 	else {
-		dev_err(&pdev->dev,
-			"%s otpc config map not defined\n", __func__);
+		dev_err(dev, "%s otpc config map not defined\n", __func__);
 		return -EINVAL;
 	}
 
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 20/21] nvmem: imx-iim: Do not use "&pdev->dev" explicitly
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

There's already "dev" variable for that. Use it.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/imx-iim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/imx-iim.c b/drivers/nvmem/imx-iim.c
index 635561a441bd..3022bd96bd7e 100644
--- a/drivers/nvmem/imx-iim.c
+++ b/drivers/nvmem/imx-iim.c
@@ -125,7 +125,7 @@ static int imx_iim_probe(struct platform_device *pdev)
 
 	drvdata = of_id->data;
 
-	iim->clk = devm_clk_get(&pdev->dev, NULL);
+	iim->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(iim->clk))
 		return PTR_ERR(iim->clk);
 
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 19/21] nvmem: rockchip-efuse: Do not use "&pdev->dev" explicitly
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

There's "dev" variable for this already. Use it.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/rockchip-efuse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c
index 979ba0a376a0..3120329aea94 100644
--- a/drivers/nvmem/rockchip-efuse.c
+++ b/drivers/nvmem/rockchip-efuse.c
@@ -202,21 +202,21 @@ static int rockchip_efuse_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	efuse = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_efuse_chip),
+	efuse = devm_kzalloc(dev, sizeof(struct rockchip_efuse_chip),
 			     GFP_KERNEL);
 	if (!efuse)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	efuse->base = devm_ioremap_resource(&pdev->dev, res);
+	efuse->base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(efuse->base))
 		return PTR_ERR(efuse->base);
 
-	efuse->clk = devm_clk_get(&pdev->dev, "pclk_efuse");
+	efuse->clk = devm_clk_get(dev, "pclk_efuse");
 	if (IS_ERR(efuse->clk))
 		return PTR_ERR(efuse->clk);
 
-	efuse->dev = &pdev->dev;
+	efuse->dev = dev;
 	econfig.size = resource_size(res);
 	econfig.reg_read = data;
 	econfig.priv = efuse;
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 18/21] nvmem: vf610-ocotp: Do not use "&pdev->dev" explicitly
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

There already a "dev" variable for that. Use it.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/vf610-ocotp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nvmem/vf610-ocotp.c b/drivers/nvmem/vf610-ocotp.c
index 752a0983e7fb..6e6bf7987d9d 100644
--- a/drivers/nvmem/vf610-ocotp.c
+++ b/drivers/nvmem/vf610-ocotp.c
@@ -223,8 +223,7 @@ static int vf610_ocotp_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct vf610_ocotp *ocotp_dev;
 
-	ocotp_dev = devm_kzalloc(&pdev->dev,
-			sizeof(struct vf610_ocotp), GFP_KERNEL);
+	ocotp_dev = devm_kzalloc(dev, sizeof(struct vf610_ocotp), GFP_KERNEL);
 	if (!ocotp_dev)
 		return -ENOMEM;
 
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 17/21] nvmem: rockchip-efuse: Make use of of_device_get_match_data()
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Simplify code a bit by using of_device_get_match_data() instead of
of_match_device().

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/rockchip-efuse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c
index d6dc1330f895..979ba0a376a0 100644
--- a/drivers/nvmem/rockchip-efuse.c
+++ b/drivers/nvmem/rockchip-efuse.c
@@ -193,11 +193,11 @@ static int rockchip_efuse_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct nvmem_device *nvmem;
 	struct rockchip_efuse_chip *efuse;
-	const struct of_device_id *match;
+	const void *data;
 	struct device *dev = &pdev->dev;
 
-	match = of_match_device(dev->driver->of_match_table, dev);
-	if (!match || !match->data) {
+	data = of_device_get_match_data(dev);
+	if (!data) {
 		dev_err(dev, "failed to get match data\n");
 		return -EINVAL;
 	}
@@ -218,7 +218,7 @@ static int rockchip_efuse_probe(struct platform_device *pdev)
 
 	efuse->dev = &pdev->dev;
 	econfig.size = resource_size(res);
-	econfig.reg_read = match->data;
+	econfig.reg_read = data;
 	econfig.priv = efuse;
 	econfig.dev = efuse->dev;
 	nvmem = devm_nvmem_register(dev, &econfig);
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 16/21] nvmem: snvs_lpgpr: Convert commas to semicolons
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Looks like commas were accidentally used where semicolons were
supposed to be. Fix that.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/snvs_lpgpr.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvmem/snvs_lpgpr.c b/drivers/nvmem/snvs_lpgpr.c
index 6a2fdd09e74a..90aaf818563b 100644
--- a/drivers/nvmem/snvs_lpgpr.c
+++ b/drivers/nvmem/snvs_lpgpr.c
@@ -110,12 +110,12 @@ static int snvs_lpgpr_probe(struct platform_device *pdev)
 	cfg->priv = priv;
 	cfg->name = dev_name(dev);
 	cfg->dev = dev;
-	cfg->stride = 4,
-	cfg->word_size = 4,
-	cfg->size = 4,
-	cfg->owner = THIS_MODULE,
-	cfg->reg_read  = snvs_lpgpr_read,
-	cfg->reg_write = snvs_lpgpr_write,
+	cfg->stride = 4;
+	cfg->word_size = 4;
+	cfg->size = 4;
+	cfg->owner = THIS_MODULE;
+	cfg->reg_read  = snvs_lpgpr_read;
+	cfg->reg_write = snvs_lpgpr_write;
 
 	nvmem = devm_nvmem_register(dev, cfg);
 	if (IS_ERR(nvmem))
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 15/21] nvmem: meson-efuse: Do no gate COMPILE_TEST with MESON_SM
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Being able to build this driver when COMPILE_TEST is selected is still
useful even when MESON_SM is not selected, since selecting this
driver as a module and doing "make modules" will result in successful
build and would detect trivial coding errors. For an example of type
of errors that could be prevented see [1] and [2]

[1] lkml.kernel.org/r/20171227225956.14442-12-andrew.smirnov at gmail.com
[2] https://marc.info/?l=linux-arm-kernel&m=151461599104358&w=2

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index ff505af064ba..42e84e1b2a26 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -147,7 +147,7 @@ config NVMEM_VF610_OCOTP
 
 config MESON_EFUSE
 	tristate "Amlogic Meson GX eFuse Support"
-	depends on (ARCH_MESON || COMPILE_TEST) && MESON_SM
+	depends on (ARCH_MESON && MESON_SM) || COMPILE_TEST
 	help
 	  This is a driver to retrieve specific values from the eFuse found on
 	  the Amlogic Meson GX SoCs.
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 14/21] nvmem: bcm-ocotp: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/bcm-ocotp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/bcm-ocotp.c b/drivers/nvmem/bcm-ocotp.c
index 5e9e324427f9..24c30fa475cc 100644
--- a/drivers/nvmem/bcm-ocotp.c
+++ b/drivers/nvmem/bcm-ocotp.c
@@ -302,27 +302,17 @@ static int bcm_otpc_probe(struct platform_device *pdev)
 
 	priv->config = &bcm_otpc_nvmem_config;
 
-	nvmem = nvmem_register(&bcm_otpc_nvmem_config);
+	nvmem = devm_nvmem_register(dev, &bcm_otpc_nvmem_config);
 	if (IS_ERR(nvmem)) {
 		dev_err(dev, "error registering nvmem config\n");
 		return PTR_ERR(nvmem);
 	}
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int bcm_otpc_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver bcm_otpc_driver = {
 	.probe	= bcm_otpc_probe,
-	.remove	= bcm_otpc_remove,
 	.driver = {
 		.name	= "brcm-otpc",
 		.of_match_table = bcm_otpc_dt_ids,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 13/21] nvmem: imx-iim: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/imx-iim.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/imx-iim.c b/drivers/nvmem/imx-iim.c
index 52cfe91d9762..635561a441bd 100644
--- a/drivers/nvmem/imx-iim.c
+++ b/drivers/nvmem/imx-iim.c
@@ -138,25 +138,15 @@ static int imx_iim_probe(struct platform_device *pdev)
 	cfg.size = drvdata->nregs;
 	cfg.priv = iim;
 
-	nvmem = nvmem_register(&cfg);
+	nvmem = devm_nvmem_register(dev, &cfg);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int imx_iim_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver imx_iim_driver = {
 	.probe	= imx_iim_probe,
-	.remove	= imx_iim_remove,
 	.driver = {
 		.name	= "imx-iim",
 		.of_match_table = imx_iim_dt_ids,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 12/21] nvmem: lpc18xx_otp: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/lpc18xx_otp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/lpc18xx_otp.c b/drivers/nvmem/lpc18xx_otp.c
index 95268db155e9..74777bfe2dcd 100644
--- a/drivers/nvmem/lpc18xx_otp.c
+++ b/drivers/nvmem/lpc18xx_otp.c
@@ -86,22 +86,13 @@ static int lpc18xx_otp_probe(struct platform_device *pdev)
 	lpc18xx_otp_nvmem_config.dev = &pdev->dev;
 	lpc18xx_otp_nvmem_config.priv = otp;
 
-	nvmem = nvmem_register(&lpc18xx_otp_nvmem_config);
+	nvmem = devm_nvmem_register(&pdev->dev, &lpc18xx_otp_nvmem_config);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int lpc18xx_otp_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static const struct of_device_id lpc18xx_otp_dt_ids[] = {
 	{ .compatible = "nxp,lpc1850-otp" },
 	{ },
@@ -110,7 +101,6 @@ MODULE_DEVICE_TABLE(of, lpc18xx_otp_dt_ids);
 
 static struct platform_driver lpc18xx_otp_driver = {
 	.probe	= lpc18xx_otp_probe,
-	.remove	= lpc18xx_otp_remove,
 	.driver = {
 		.name	= "lpc18xx_otp",
 		.of_match_table = lpc18xx_otp_dt_ids,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 11/21] nvmem: meson-efuse: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:23 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/meson-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/meson-efuse.c b/drivers/nvmem/meson-efuse.c
index a43c68f90937..66029fc85ba9 100644
--- a/drivers/nvmem/meson-efuse.c
+++ b/drivers/nvmem/meson-efuse.c
@@ -60,25 +60,15 @@ static int meson_efuse_probe(struct platform_device *pdev)
 	econfig.reg_read = meson_efuse_read;
 	econfig.size = size;
 
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(&pdev->dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int meson_efuse_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver meson_efuse_driver = {
 	.probe = meson_efuse_probe,
-	.remove = meson_efuse_remove,
 	.driver = {
 		.name = "meson-efuse",
 		.of_match_table = meson_efuse_match,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 10/21] nvmem: meson-mx-efuse: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/meson-mx-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/meson-mx-efuse.c b/drivers/nvmem/meson-mx-efuse.c
index a346b4923550..f8e0b92e40ba 100644
--- a/drivers/nvmem/meson-mx-efuse.c
+++ b/drivers/nvmem/meson-mx-efuse.c
@@ -233,25 +233,15 @@ static int meson_mx_efuse_probe(struct platform_device *pdev)
 		return PTR_ERR(efuse->core_clk);
 	}
 
-	efuse->nvmem = nvmem_register(&efuse->config);
+	efuse->nvmem = devm_nvmem_register(&pdev->dev, &efuse->config);
 	if (IS_ERR(efuse->nvmem))
 		return PTR_ERR(efuse->nvmem);
 
-	platform_set_drvdata(pdev, efuse);
-
 	return 0;
 }
 
-static int meson_mx_efuse_remove(struct platform_device *pdev)
-{
-	struct meson_mx_efuse *efuse = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(efuse->nvmem);
-}
-
 static struct platform_driver meson_mx_efuse_driver = {
 	.probe = meson_mx_efuse_probe,
-	.remove = meson_mx_efuse_remove,
 	.driver = {
 		.name = "meson-mx-efuse",
 		.of_match_table = meson_mx_efuse_match,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 09/21] nvmem: mtk-efuse: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/mtk-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index 9ee3479cfc7b..97ab7e6a4789 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -72,22 +72,13 @@ static int mtk_efuse_probe(struct platform_device *pdev)
 	econfig.size = resource_size(res);
 	econfig.priv = priv;
 	econfig.dev = dev;
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int mtk_efuse_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static const struct of_device_id mtk_efuse_of_match[] = {
 	{ .compatible = "mediatek,mt8173-efuse",},
 	{ .compatible = "mediatek,efuse",},
@@ -97,7 +88,6 @@ MODULE_DEVICE_TABLE(of, mtk_efuse_of_match);
 
 static struct platform_driver mtk_efuse_driver = {
 	.probe = mtk_efuse_probe,
-	.remove = mtk_efuse_remove,
 	.driver = {
 		.name = "mediatek,efuse",
 		.of_match_table = mtk_efuse_of_match,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 08/21] nvmem: qfprom: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/qfprom.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c
index cb3b48b47d64..13bf43c84bd4 100644
--- a/drivers/nvmem/qfprom.c
+++ b/drivers/nvmem/qfprom.c
@@ -47,13 +47,6 @@ static int qfprom_reg_write(void *context,
 	return 0;
 }
 
-static int qfprom_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct nvmem_config econfig = {
 	.name = "qfprom",
 	.stride = 1,
@@ -82,12 +75,10 @@ static int qfprom_probe(struct platform_device *pdev)
 	econfig.dev = dev;
 	econfig.priv = priv;
 
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
@@ -99,7 +90,6 @@ MODULE_DEVICE_TABLE(of, qfprom_of_match);
 
 static struct platform_driver qfprom_driver = {
 	.probe = qfprom_probe,
-	.remove = qfprom_remove,
 	.driver = {
 		.name = "qcom,qfprom",
 		.of_match_table = qfprom_of_match,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 07/21] nvmem: rockchip-efuse: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/rockchip-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c
index 123de77ca5d6..d6dc1330f895 100644
--- a/drivers/nvmem/rockchip-efuse.c
+++ b/drivers/nvmem/rockchip-efuse.c
@@ -221,25 +221,15 @@ static int rockchip_efuse_probe(struct platform_device *pdev)
 	econfig.reg_read = match->data;
 	econfig.priv = efuse;
 	econfig.dev = efuse->dev;
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int rockchip_efuse_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver rockchip_efuse_driver = {
 	.probe = rockchip_efuse_probe,
-	.remove = rockchip_efuse_remove,
 	.driver = {
 		.name = "rockchip-efuse",
 		.of_match_table = rockchip_efuse_match,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 06/21] nvmem: snvs_lgpr: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/snvs_lpgpr.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/snvs_lpgpr.c b/drivers/nvmem/snvs_lpgpr.c
index e5c2a4a17f03..6a2fdd09e74a 100644
--- a/drivers/nvmem/snvs_lpgpr.c
+++ b/drivers/nvmem/snvs_lpgpr.c
@@ -117,22 +117,13 @@ static int snvs_lpgpr_probe(struct platform_device *pdev)
 	cfg->reg_read  = snvs_lpgpr_read,
 	cfg->reg_write = snvs_lpgpr_write,
 
-	nvmem = nvmem_register(cfg);
+	nvmem = devm_nvmem_register(dev, cfg);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int snvs_lpgpr_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static const struct of_device_id snvs_lpgpr_dt_ids[] = {
 	{ .compatible = "fsl,imx6q-snvs-lpgpr", .data = &snvs_lpgpr_cfg_imx6q },
 	{ .compatible = "fsl,imx6ul-snvs-lpgpr",
@@ -143,7 +134,6 @@ MODULE_DEVICE_TABLE(of, snvs_lpgpr_dt_ids);
 
 static struct platform_driver snvs_lpgpr_driver = {
 	.probe	= snvs_lpgpr_probe,
-	.remove	= snvs_lpgpr_remove,
 	.driver = {
 		.name	= "snvs_lpgpr",
 		.of_match_table = snvs_lpgpr_dt_ids,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 05/21] nvmem: uniphier-efuse: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/uniphier-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/uniphier-efuse.c b/drivers/nvmem/uniphier-efuse.c
index 9d278b4e1dc7..7ddc6fc012c9 100644
--- a/drivers/nvmem/uniphier-efuse.c
+++ b/drivers/nvmem/uniphier-efuse.c
@@ -60,22 +60,13 @@ static int uniphier_efuse_probe(struct platform_device *pdev)
 	econfig.size = resource_size(res);
 	econfig.priv = priv;
 	econfig.dev = dev;
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int uniphier_efuse_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static const struct of_device_id uniphier_efuse_of_match[] = {
 	{ .compatible = "socionext,uniphier-efuse",},
 	{/* sentinel */},
@@ -84,7 +75,6 @@ MODULE_DEVICE_TABLE(of, uniphier_efuse_of_match);
 
 static struct platform_driver uniphier_efuse_driver = {
 	.probe = uniphier_efuse_probe,
-	.remove = uniphier_efuse_remove,
 	.driver = {
 		.name = "uniphier-efuse",
 		.of_match_table = uniphier_efuse_of_match,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 04/21] nvmem: imx-ocotp: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/imx-ocotp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c
index d7ba351a70c9..68deffe636f3 100644
--- a/drivers/nvmem/imx-ocotp.c
+++ b/drivers/nvmem/imx-ocotp.c
@@ -466,26 +466,16 @@ static int imx_ocotp_probe(struct platform_device *pdev)
 	imx_ocotp_nvmem_config.dev = dev;
 	imx_ocotp_nvmem_config.priv = priv;
 	priv->config = &imx_ocotp_nvmem_config;
-	nvmem = nvmem_register(&imx_ocotp_nvmem_config);
+	nvmem = devm_nvmem_register(dev, &imx_ocotp_nvmem_config);
 
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int imx_ocotp_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver imx_ocotp_driver = {
 	.probe	= imx_ocotp_probe,
-	.remove	= imx_ocotp_remove,
 	.driver = {
 		.name	= "imx_ocotp",
 		.of_match_table = imx_ocotp_dt_ids,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 03/21] nvmem: vf610-ocotp: Convert to use devm_nvmem_register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Drop all of the code related to .remove hook and make use of
devm_nvmem_register() instead.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/vf610-ocotp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/nvmem/vf610-ocotp.c b/drivers/nvmem/vf610-ocotp.c
index 5ae9e002f195..752a0983e7fb 100644
--- a/drivers/nvmem/vf610-ocotp.c
+++ b/drivers/nvmem/vf610-ocotp.c
@@ -217,13 +217,6 @@ static const struct of_device_id ocotp_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ocotp_of_match);
 
-static int vf610_ocotp_remove(struct platform_device *pdev)
-{
-	struct vf610_ocotp *ocotp_dev = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(ocotp_dev->nvmem);
-}
-
 static int vf610_ocotp_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -251,13 +244,11 @@ static int vf610_ocotp_probe(struct platform_device *pdev)
 	ocotp_config.priv = ocotp_dev;
 	ocotp_config.dev = dev;
 
-	ocotp_dev->nvmem = nvmem_register(&ocotp_config);
+	ocotp_dev->nvmem = devm_nvmem_register(dev, &ocotp_config);
 	if (IS_ERR(ocotp_dev->nvmem))
 		return PTR_ERR(ocotp_dev->nvmem);
 
 	ocotp_dev->dev = dev;
-	platform_set_drvdata(pdev, ocotp_dev);
-
 	ocotp_dev->timing = vf610_ocotp_calculate_timing(ocotp_dev);
 
 	return 0;
@@ -265,7 +256,6 @@ static int vf610_ocotp_probe(struct platform_device *pdev)
 
 static struct platform_driver vf610_ocotp_driver = {
 	.probe = vf610_ocotp_probe,
-	.remove = vf610_ocotp_remove,
 	.driver = {
 		.name = "vf610-ocotp",
 		.of_match_table = ocotp_of_match,
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 02/21] nvmem: Introduce devm_nvmem_(un)register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Introduce devm_nvmem_register()/devm_nvmem_unregister() to make
.remove() unnecessary in trivial drivers.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/core.c           | 41 +++++++++++++++++++++++++++++++++++++++++
 include/linux/nvmem-provider.h | 17 +++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 57cbeacfbeb2..84f07ba1f36d 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -551,6 +551,47 @@ int nvmem_unregister(struct nvmem_device *nvmem)
 }
 EXPORT_SYMBOL_GPL(nvmem_unregister);
 
+static void devm_nvmem_release(struct device *dev, void *res)
+{
+	WARN_ON(nvmem_unregister(*(struct nvmem_device **)res));
+}
+
+struct nvmem_device *devm_nvmem_register(struct device *dev,
+					 const struct nvmem_config *config)
+{
+	struct nvmem_device **ptr, *nvmem;
+
+	ptr = devres_alloc(devm_nvmem_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return ERR_PTR(-ENOMEM);
+
+	nvmem = nvmem_register(config);
+
+	if (!IS_ERR(nvmem)) {
+		*ptr = nvmem;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return nvmem;
+}
+EXPORT_SYMBOL_GPL(devm_nvmem_register);
+
+static int devm_nvmem_match(struct device *dev, void *res, void *data)
+{
+	struct nvmem_device **r = res;
+
+	return *r == data;
+}
+
+int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
+{
+	return devres_release(dev, devm_nvmem_release, devm_nvmem_match, nvmem);
+}
+EXPORT_SYMBOL(devm_nvmem_unregister);
+
+
 static struct nvmem_device *__nvmem_device_get(struct device_node *np,
 					       struct nvmem_cell **cellp,
 					       const char *cell_id)
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 497706f5adca..493f2f529f00 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -47,6 +47,11 @@ struct nvmem_config {
 struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
 int nvmem_unregister(struct nvmem_device *nvmem);
 
+struct nvmem_device *devm_nvmem_register(struct device *dev,
+					 const struct nvmem_config *cfg);
+
+int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem);
+
 #else
 
 static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
@@ -59,5 +64,17 @@ static inline int nvmem_unregister(struct nvmem_device *nvmem)
 	return -ENOSYS;
 }
 
+static inline struct nvmem_device *
+devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
+{
+	return nvmem_register(c);
+}
+
+static inline int
+devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
+{
+	return nvmem_unregister(nvmem);
+}
+
 #endif /* CONFIG_NVMEM */
 #endif  /* ifndef _LINUX_NVMEM_PROVIDER_H */
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 01/21] nvmem: core: Allow specifying device name verbatim
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101232310.30420-1-andrew.smirnov@gmail.com>

Add code to allow avoid having nvmem core append a numeric suffix to
the end of the name by passing config->id of -1.

Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: cphealy at gmail.com
Cc: linux-kernel at vger.kernel.org
Cc: linux-mediatek at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: linux-amlogic at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/nvmem/core.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 5a5cefd12153..57cbeacfbeb2 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -475,9 +475,14 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	nvmem->reg_write = config->reg_write;
 	np = config->dev->of_node;
 	nvmem->dev.of_node = np;
-	dev_set_name(&nvmem->dev, "%s%d",
-		     config->name ? : "nvmem",
-		     config->name ? config->id : nvmem->id);
+
+	if (config->id == -1 && config->name) {
+		dev_set_name(&nvmem->dev, "%s", config->name);
+	} else {
+		dev_set_name(&nvmem->dev, "%s%d",
+			     config->name ? : "nvmem",
+			     config->name ? config->id : nvmem->id);
+	}
 
 	nvmem->read_only = of_property_read_bool(np, "read-only") |
 			   config->read_only;
-- 
2.14.3

^ permalink raw reply related

* [PATCH v2 00/21] Verbatim device names and devm_nvmem_(un)register()
From: Andrey Smirnov @ 2018-01-01 23:22 UTC (permalink / raw)
  To: linux-arm-kernel

Srinivas, all:

This patchset contains various small changes that I recently made to
NVMEM, more specifically:

 - Patches 1 and 2 are two changes I am hoping are acceptable upstream

 - Patches 3 to 14 are a follow up to patch 2

 - Patches 15 to 21 are just trivial fixups and I am more than happy
   to drop them if they seem to add more pointless churn rather then
   value.

Feedback is appreciated!

Thanks,
Andrey Smirnov


Changes since [v1]:

 - Fixed a build break detected by kbuild test robot

 - Added a patch to unconditionally enable COMPILE_TEST for meson-efuse

 - Dropped Joachim Eastwood from CC list due to bouncing e-mail


[v1] lkml.kernel.org/r/20171227225956.14442-1-andrew.smirnov at gmail.com


Andrey Smirnov (21):
  nvmem: core: Allow specifying device name verbatim
  nvmem: Introduce devm_nvmem_(un)register()
  nvmem: vf610-ocotp: Convert to use devm_nvmem_register()
  nvmem: imx-ocotp: Convert to use devm_nvmem_register()
  nvmem: uniphier-efuse: Convert to use devm_nvmem_register()
  nvmem: snvs_lgpr: Convert to use devm_nvmem_register()
  nvmem: rockchip-efuse: Convert to use devm_nvmem_register()
  nvmem: qfprom: Convert to use devm_nvmem_register()
  nvmem: mtk-efuse: Convert to use devm_nvmem_register()
  nvmem: meson-mx-efuse: Convert to use devm_nvmem_register()
  nvmem: meson-efuse: Convert to use devm_nvmem_register()
  nvmem: lpc18xx_otp: Convert to use devm_nvmem_register()
  nvmem: imx-iim: Convert to use devm_nvmem_register()
  nvmem: bcm-ocotp: Convert to use devm_nvmem_register()
  nvmem: meson-efuse: Do no gate COMPILE_TEST with MESON_SM
  nvmem: snvs_lpgpr: Convert commas to semicolons
  nvmem: rockchip-efuse: Make use of of_device_get_match_data()
  nvmem: vf610-ocotp: Do not use "&pdev->dev" explicitly
  nvmem: rockchip-efuse: Do not use "&pdev->dev" explicitly
  nvmem: imx-iim: Do not use "&pdev->dev" explicitly
  nvmem: bcm-ocotp: Do not use "&pdev->dev" explicitly

 drivers/nvmem/Kconfig          |  2 +-
 drivers/nvmem/bcm-ocotp.c      | 15 ++----------
 drivers/nvmem/core.c           | 52 +++++++++++++++++++++++++++++++++++++++---
 drivers/nvmem/imx-iim.c        | 14 ++----------
 drivers/nvmem/imx-ocotp.c      | 12 +---------
 drivers/nvmem/lpc18xx_otp.c    | 12 +---------
 drivers/nvmem/meson-efuse.c    | 12 +---------
 drivers/nvmem/meson-mx-efuse.c | 12 +---------
 drivers/nvmem/mtk-efuse.c      | 12 +---------
 drivers/nvmem/qfprom.c         | 12 +---------
 drivers/nvmem/rockchip-efuse.c | 28 ++++++++---------------
 drivers/nvmem/snvs_lpgpr.c     | 26 +++++++--------------
 drivers/nvmem/uniphier-efuse.c | 12 +---------
 drivers/nvmem/vf610-ocotp.c    | 15 ++----------
 include/linux/nvmem-provider.h | 17 ++++++++++++++
 15 files changed, 97 insertions(+), 156 deletions(-)

-- 
2.14.3

^ permalink raw reply

* [PATCH v2] ARM: dts: imx6: RDU2: disable internal watchdog
From: Fabio Estevam @ 2018-01-01 21:50 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20180101212451.11516-1-andrew.smirnov@gmail.com>

Hi Andrey,

On Mon, Jan 1, 2018 at 7:24 PM, Andrey Smirnov <andrew.smirnov@gmail.com> wrote:

> diff --git a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
> index 6bef9a98678e..818bfc8692a5 100644
> --- a/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
> @@ -838,6 +838,10 @@
>         status = "okay";
>  };
>
> +&wdog1 {
> +       status = "disabled";
> +};
> +
>  &audmux {

We should keep the nodes in alphabetical order. Other than that:

Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox