All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: Evan Green <evgreen@chromium.org>
Cc: Andy Gross <andy.gross@linaro.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Ben Chan <benchan@chromium.org>,
	linux-arm-msm@vger.kernel.org,
	David Brown <david.brown@linaro.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] soc: qcom: rmtfs-mem: Add class to enable uevents
Date: Thu, 20 Dec 2018 17:18:54 -0800	[thread overview]
Message-ID: <20181221011853.GA189656@google.com> (raw)
In-Reply-To: <20181218000834.201748-2-evgreen@chromium.org>

Hi Evan,

On Mon, Dec 17, 2018 at 04:08:33PM -0800, Evan Green wrote:
> Currently the qcom_rmtfs_memN devices are entirely invisible to the udev world.
> Add a class to the rmtfs device so that uevents fire when the device is added.
> 
> Signed-off-by: Evan Green <evgreen@chromium.org>
> ---
> 
>  drivers/soc/qcom/rmtfs_mem.c | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
> index 97bb5989aa211..0bf800ee2a978 100644
> --- a/drivers/soc/qcom/rmtfs_mem.c
> +++ b/drivers/soc/qcom/rmtfs_mem.c
> @@ -132,6 +132,11 @@ static int qcom_rmtfs_mem_release(struct inode *inode, struct file *filp)
>  	return 0;
>  }
>  
> +static struct class rmtfs_class = {
> +	.owner          = THIS_MODULE,
> +	.name           = "rmtfs",
> +};
> +
>  static const struct file_operations qcom_rmtfs_mem_fops = {
>  	.owner = THIS_MODULE,
>  	.open = qcom_rmtfs_mem_open,
> @@ -173,9 +178,15 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
>  
>  	}
>  
> +	ret  = class_register(&rmtfs_class);
> +	if (ret)
> +		return ret;

Hmm, is this how classes are supposed to work? Usually, you have the
possibility of more than 1 device per class, and therefore you don't
register the class in the driver probe -- you register it in the init()
routine, or something similar. As it is, I expect this will break if
there were ever a second rmtfs device.

Brian

> +
>  	rmtfs_mem = kzalloc(sizeof(*rmtfs_mem), GFP_KERNEL);
> -	if (!rmtfs_mem)
> -		return -ENOMEM;
> +	if (!rmtfs_mem) {
> +		ret = -ENOMEM;
> +		goto unregister_class;
> +	}
>  
>  	rmtfs_mem->addr = rmem->base;
>  	rmtfs_mem->client_id = client_id;
> @@ -199,8 +210,8 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
>  
>  	dev_set_name(&rmtfs_mem->dev, "qcom_rmtfs_mem%d", client_id);
>  	rmtfs_mem->dev.id = client_id;
> +	rmtfs_mem->dev.class = &rmtfs_class;
>  	rmtfs_mem->dev.devt = MKDEV(MAJOR(qcom_rmtfs_mem_major), client_id);
> -
>  	ret = cdev_device_add(&rmtfs_mem->cdev, &rmtfs_mem->dev);
>  	if (ret) {
>  		dev_err(&pdev->dev, "failed to add cdev: %d\n", ret);
> @@ -235,11 +246,13 @@ static int qcom_rmtfs_mem_probe(struct platform_device *pdev)
>  
>  	return 0;
>  
> +
>  remove_cdev:
>  	cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev);
>  put_device:
>  	put_device(&rmtfs_mem->dev);
> -
> +unregister_class:
> +	class_unregister(&rmtfs_class);
>  	return ret;
>  }
>  
> @@ -258,7 +271,7 @@ static int qcom_rmtfs_mem_remove(struct platform_device *pdev)
>  
>  	cdev_device_del(&rmtfs_mem->cdev, &rmtfs_mem->dev);
>  	put_device(&rmtfs_mem->dev);
> -
> +	class_unregister(&rmtfs_class);
>  	return 0;
>  }
>  
> -- 
> 2.18.1
> 

  reply	other threads:[~2018-12-21  1:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18  0:08 [PATCH v1 0/2] soc: qcom: rmtfs-mem: Support non-root rmtfs daemons Evan Green
2018-12-18  0:08 ` [PATCH v1 1/2] soc: qcom: rmtfs-mem: Add class to enable uevents Evan Green
2018-12-21  1:18   ` Brian Norris [this message]
2018-12-21 17:56     ` Evan Green
2018-12-18  0:08 ` [PATCH v1 2/2] soc: qcom: rmtfs-mem: Make sysfs attributes world-readable Evan Green
2018-12-21  1:21   ` Brian Norris

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=20181221011853.GA189656@google.com \
    --to=briannorris@chromium.org \
    --cc=andy.gross@linaro.org \
    --cc=benchan@chromium.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=david.brown@linaro.org \
    --cc=evgreen@chromium.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.