linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] nvmem: use is_bin_visible callback
@ 2020-03-24 17:15 Srinivas Kandagatla
  2020-03-24 17:15 ` [PATCH 1/3] nvmem: core: use device_register and device_unregister Srinivas Kandagatla
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Srinivas Kandagatla @ 2020-03-24 17:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, nicholas.johnson-opensource, Srinivas Kandagatla

Hi Greg,

As suggested I managed to use is_bin_visible for the existing code and
one cleanup for using device_register/unregister directly instead of splitting.

Note: this does not add any new functionality, its just a cleanup

Thanks,
srini

Srinivas Kandagatla (3):
  nvmem: core: use device_register and device_unregister
  nvmem: core: add root_only member to nvmem device struct
  nvmem: core: use is_bin_visible for permissions

 drivers/nvmem/core.c        |  8 ++--
 drivers/nvmem/nvmem-sysfs.c | 74 +++++++++----------------------------
 drivers/nvmem/nvmem.h       |  1 +
 3 files changed, 22 insertions(+), 61 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] nvmem: core: use device_register and device_unregister
  2020-03-24 17:15 [PATCH 0/3] nvmem: use is_bin_visible callback Srinivas Kandagatla
@ 2020-03-24 17:15 ` Srinivas Kandagatla
  2020-03-24 17:15 ` [PATCH 2/3] nvmem: core: add root_only member to nvmem device struct Srinivas Kandagatla
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Srinivas Kandagatla @ 2020-03-24 17:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, nicholas.johnson-opensource, Srinivas Kandagatla

use device_register/unregister instead of spliting them with no use.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 77d890d3623d..e8f7bea93abf 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -397,11 +397,9 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 
 	nvmem->dev.groups = nvmem_sysfs_get_groups(nvmem, config);
 
-	device_initialize(&nvmem->dev);
-
 	dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
 
-	rval = device_add(&nvmem->dev);
+	rval = device_register(&nvmem->dev);
 	if (rval)
 		goto err_put_device;
 
@@ -455,8 +453,7 @@ static void nvmem_device_release(struct kref *kref)
 		device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
 
 	nvmem_device_remove_all_cells(nvmem);
-	device_del(&nvmem->dev);
-	put_device(&nvmem->dev);
+	device_unregister(&nvmem->dev);
 }
 
 /**
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] nvmem: core: add root_only member to nvmem device struct
  2020-03-24 17:15 [PATCH 0/3] nvmem: use is_bin_visible callback Srinivas Kandagatla
  2020-03-24 17:15 ` [PATCH 1/3] nvmem: core: use device_register and device_unregister Srinivas Kandagatla
@ 2020-03-24 17:15 ` Srinivas Kandagatla
  2020-03-24 17:16 ` [PATCH 3/3] nvmem: core: use is_bin_visible for permissions Srinivas Kandagatla
  2020-03-24 17:58 ` [PATCH 0/3] nvmem: use is_bin_visible callback Greg KH
  3 siblings, 0 replies; 10+ messages in thread
From: Srinivas Kandagatla @ 2020-03-24 17:15 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, nicholas.johnson-opensource, Srinivas Kandagatla

As we are planning to move to use sysfs is_bin_visible callback,
having root_only as part of nvmem_device will help decide correct
permissions.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c  | 1 +
 drivers/nvmem/nvmem.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index e8f7bea93abf..7d28e1cca4e0 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -377,6 +377,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	nvmem->dev.type = &nvmem_provider_type;
 	nvmem->dev.bus = &nvmem_bus_type;
 	nvmem->dev.parent = config->dev;
+	nvmem->root_only = config->root_only;
 	nvmem->priv = config->priv;
 	nvmem->type = config->type;
 	nvmem->reg_read = config->reg_read;
diff --git a/drivers/nvmem/nvmem.h b/drivers/nvmem/nvmem.h
index be0d66d75c8a..16c0d3ad6679 100644
--- a/drivers/nvmem/nvmem.h
+++ b/drivers/nvmem/nvmem.h
@@ -20,6 +20,7 @@ struct nvmem_device {
 	struct kref		refcnt;
 	size_t			size;
 	bool			read_only;
+	bool			root_only;
 	int			flags;
 	enum nvmem_type		type;
 	struct bin_attribute	eeprom;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] nvmem: core: use is_bin_visible for permissions
  2020-03-24 17:15 [PATCH 0/3] nvmem: use is_bin_visible callback Srinivas Kandagatla
  2020-03-24 17:15 ` [PATCH 1/3] nvmem: core: use device_register and device_unregister Srinivas Kandagatla
  2020-03-24 17:15 ` [PATCH 2/3] nvmem: core: add root_only member to nvmem device struct Srinivas Kandagatla
@ 2020-03-24 17:16 ` Srinivas Kandagatla
  2020-03-24 17:46   ` Greg KH
  2020-03-24 23:05   ` Nicholas Johnson
  2020-03-24 17:58 ` [PATCH 0/3] nvmem: use is_bin_visible callback Greg KH
  3 siblings, 2 replies; 10+ messages in thread
From: Srinivas Kandagatla @ 2020-03-24 17:16 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, nicholas.johnson-opensource, Srinivas Kandagatla

By using is_bin_visible callback to set permissions will remove a large list
of attribute groups. These group permissions can be dynamically derived in
the callback.

Suggested-by: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/nvmem-sysfs.c | 74 +++++++++----------------------------
 1 file changed, 18 insertions(+), 56 deletions(-)

diff --git a/drivers/nvmem/nvmem-sysfs.c b/drivers/nvmem/nvmem-sysfs.c
index 8759c4470012..1ff1801048f6 100644
--- a/drivers/nvmem/nvmem-sysfs.c
+++ b/drivers/nvmem/nvmem-sysfs.c
@@ -103,6 +103,17 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
 
 	return count;
 }
+static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
+					 struct bin_attribute *attr, int i)
+{
+	struct device *dev = container_of(kobj, struct device, kobj);
+	struct nvmem_device *nvmem = to_nvmem_device(dev);
+
+	if (nvmem->root_only)
+		return nvmem->read_only ? 0400 : 0600;
+
+	return nvmem->read_only ? 0444 : 0644;
+}
 
 /* default read/write permissions */
 static struct bin_attribute bin_attr_rw_nvmem = {
@@ -114,18 +125,19 @@ static struct bin_attribute bin_attr_rw_nvmem = {
 	.write	= bin_attr_nvmem_write,
 };
 
-static struct bin_attribute *nvmem_bin_rw_attributes[] = {
+static struct bin_attribute *nvmem_bin_attributes[] = {
 	&bin_attr_rw_nvmem,
 	NULL,
 };
 
-static const struct attribute_group nvmem_bin_rw_group = {
-	.bin_attrs	= nvmem_bin_rw_attributes,
+static const struct attribute_group nvmem_bin_group = {
+	.bin_attrs	= nvmem_bin_attributes,
 	.attrs		= nvmem_attrs,
+	.is_bin_visible = nvmem_bin_attr_is_visible,
 };
 
-static const struct attribute_group *nvmem_rw_dev_groups[] = {
-	&nvmem_bin_rw_group,
+static const struct attribute_group *nvmem_dev_groups[] = {
+	&nvmem_bin_group,
 	NULL,
 };
 
@@ -138,21 +150,6 @@ static struct bin_attribute bin_attr_ro_nvmem = {
 	.read	= bin_attr_nvmem_read,
 };
 
-static struct bin_attribute *nvmem_bin_ro_attributes[] = {
-	&bin_attr_ro_nvmem,
-	NULL,
-};
-
-static const struct attribute_group nvmem_bin_ro_group = {
-	.bin_attrs	= nvmem_bin_ro_attributes,
-	.attrs		= nvmem_attrs,
-};
-
-static const struct attribute_group *nvmem_ro_dev_groups[] = {
-	&nvmem_bin_ro_group,
-	NULL,
-};
-
 /* default read/write permissions, root only */
 static struct bin_attribute bin_attr_rw_root_nvmem = {
 	.attr	= {
@@ -163,21 +160,6 @@ static struct bin_attribute bin_attr_rw_root_nvmem = {
 	.write	= bin_attr_nvmem_write,
 };
 
-static struct bin_attribute *nvmem_bin_rw_root_attributes[] = {
-	&bin_attr_rw_root_nvmem,
-	NULL,
-};
-
-static const struct attribute_group nvmem_bin_rw_root_group = {
-	.bin_attrs	= nvmem_bin_rw_root_attributes,
-	.attrs		= nvmem_attrs,
-};
-
-static const struct attribute_group *nvmem_rw_root_dev_groups[] = {
-	&nvmem_bin_rw_root_group,
-	NULL,
-};
-
 /* read only permission, root only */
 static struct bin_attribute bin_attr_ro_root_nvmem = {
 	.attr	= {
@@ -187,31 +169,11 @@ static struct bin_attribute bin_attr_ro_root_nvmem = {
 	.read	= bin_attr_nvmem_read,
 };
 
-static struct bin_attribute *nvmem_bin_ro_root_attributes[] = {
-	&bin_attr_ro_root_nvmem,
-	NULL,
-};
-
-static const struct attribute_group nvmem_bin_ro_root_group = {
-	.bin_attrs	= nvmem_bin_ro_root_attributes,
-	.attrs		= nvmem_attrs,
-};
-
-static const struct attribute_group *nvmem_ro_root_dev_groups[] = {
-	&nvmem_bin_ro_root_group,
-	NULL,
-};
-
 const struct attribute_group **nvmem_sysfs_get_groups(
 					struct nvmem_device *nvmem,
 					const struct nvmem_config *config)
 {
-	if (config->root_only)
-		return nvmem->read_only ?
-			nvmem_ro_root_dev_groups :
-			nvmem_rw_root_dev_groups;
-
-	return nvmem->read_only ? nvmem_ro_dev_groups : nvmem_rw_dev_groups;
+	return nvmem_dev_groups;
 }
 
 /*
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] nvmem: core: use is_bin_visible for permissions
  2020-03-24 17:16 ` [PATCH 3/3] nvmem: core: use is_bin_visible for permissions Srinivas Kandagatla
@ 2020-03-24 17:46   ` Greg KH
  2020-03-25  9:15     ` Srinivas Kandagatla
  2020-03-24 23:05   ` Nicholas Johnson
  1 sibling, 1 reply; 10+ messages in thread
From: Greg KH @ 2020-03-24 17:46 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: linux-kernel, nicholas.johnson-opensource

On Tue, Mar 24, 2020 at 05:16:00PM +0000, Srinivas Kandagatla wrote:
> By using is_bin_visible callback to set permissions will remove a large list
> of attribute groups. These group permissions can be dynamically derived in
> the callback.
> 
> Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/nvmem/nvmem-sysfs.c | 74 +++++++++----------------------------
>  1 file changed, 18 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/nvmem/nvmem-sysfs.c b/drivers/nvmem/nvmem-sysfs.c
> index 8759c4470012..1ff1801048f6 100644
> --- a/drivers/nvmem/nvmem-sysfs.c
> +++ b/drivers/nvmem/nvmem-sysfs.c
> @@ -103,6 +103,17 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
>  
>  	return count;
>  }
> +static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
> +					 struct bin_attribute *attr, int i)
> +{
> +	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct nvmem_device *nvmem = to_nvmem_device(dev);
> +
> +	if (nvmem->root_only)
> +		return nvmem->read_only ? 0400 : 0600;
> +
> +	return nvmem->read_only ? 0444 : 0644;
> +}

I don't know why this is so hard for me to read, but how about this
instead:

static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
					 struct bin_attribute *attr, int i)
{
	struct device *dev = container_of(kobj, struct device, kobj);
	struct nvmem_device *nvmem = to_nvmem_device(dev);
	umode_t mode = 0400;

	if (!nvmem->root_only)
		mode |= 0044;

	if (!nvmem->read_only)
		mode |= 0200;

	return mode;
}

Did I get the logic corect?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/3] nvmem: use is_bin_visible callback
  2020-03-24 17:15 [PATCH 0/3] nvmem: use is_bin_visible callback Srinivas Kandagatla
                   ` (2 preceding siblings ...)
  2020-03-24 17:16 ` [PATCH 3/3] nvmem: core: use is_bin_visible for permissions Srinivas Kandagatla
@ 2020-03-24 17:58 ` Greg KH
  3 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2020-03-24 17:58 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: linux-kernel, nicholas.johnson-opensource

On Tue, Mar 24, 2020 at 05:15:57PM +0000, Srinivas Kandagatla wrote:
> Hi Greg,
> 
> As suggested I managed to use is_bin_visible for the existing code and
> one cleanup for using device_register/unregister directly instead of splitting.
> 
> Note: this does not add any new functionality, its just a cleanup

I took patch 1 of this series already, as it was "obvious" :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] nvmem: core: use is_bin_visible for permissions
  2020-03-24 17:16 ` [PATCH 3/3] nvmem: core: use is_bin_visible for permissions Srinivas Kandagatla
  2020-03-24 17:46   ` Greg KH
@ 2020-03-24 23:05   ` Nicholas Johnson
  2020-03-25  7:36     ` gregkh
  2020-03-25  9:36     ` Srinivas Kandagatla
  1 sibling, 2 replies; 10+ messages in thread
From: Nicholas Johnson @ 2020-03-24 23:05 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: gregkh, linux-kernel

On Tue, Mar 24, 2020 at 05:16:00PM +0000, Srinivas Kandagatla wrote:
> By using is_bin_visible callback to set permissions will remove a large list
> of attribute groups. These group permissions can be dynamically derived in
> the callback.
> 
> Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/nvmem/nvmem-sysfs.c | 74 +++++++++----------------------------
>  1 file changed, 18 insertions(+), 56 deletions(-)
> 
> diff --git a/drivers/nvmem/nvmem-sysfs.c b/drivers/nvmem/nvmem-sysfs.c
> index 8759c4470012..1ff1801048f6 100644
> --- a/drivers/nvmem/nvmem-sysfs.c
> +++ b/drivers/nvmem/nvmem-sysfs.c
> @@ -103,6 +103,17 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
>  
>  	return count;
>  }
> +static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
> +					 struct bin_attribute *attr, int i)
> +{
> +	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct nvmem_device *nvmem = to_nvmem_device(dev);
> +
> +	if (nvmem->root_only)
> +		return nvmem->read_only ? 0400 : 0600;
> +
> +	return nvmem->read_only ? 0444 : 0644;
> +}
Looks like I did a pretty good job as I arrived at a similar result 
independently. Even added root_only to nvmem_device. You beat me to it. 
:)

>  const struct attribute_group **nvmem_sysfs_get_groups(
>  					struct nvmem_device *nvmem,
>  					const struct nvmem_config *config)
>  {
> -	if (config->root_only)
> -		return nvmem->read_only ?
> -			nvmem_ro_root_dev_groups :
> -			nvmem_rw_root_dev_groups;
> -
> -	return nvmem->read_only ? nvmem_ro_dev_groups : nvmem_rw_dev_groups;
> +	return nvmem_dev_groups;
>  }
I was wondering if we can export nvmem_dev_group instead of this 
nvmem_sysfs_get_groups() to fetch it.

Also, we need some logic in nvmem_register() to abort if bad combination 
is given (i.e. root_only set but no reg_read), as returning 0 in 
is_bin_visible callback does not abort. I can do that in my patch if you 
want.

Regards,
Nicholas
>  
>  /*
> -- 
> 2.21.0
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] nvmem: core: use is_bin_visible for permissions
  2020-03-24 23:05   ` Nicholas Johnson
@ 2020-03-25  7:36     ` gregkh
  2020-03-25  9:36     ` Srinivas Kandagatla
  1 sibling, 0 replies; 10+ messages in thread
From: gregkh @ 2020-03-25  7:36 UTC (permalink / raw)
  To: Nicholas Johnson; +Cc: Srinivas Kandagatla, linux-kernel

On Tue, Mar 24, 2020 at 11:05:07PM +0000, Nicholas Johnson wrote:
> On Tue, Mar 24, 2020 at 05:16:00PM +0000, Srinivas Kandagatla wrote:
> > By using is_bin_visible callback to set permissions will remove a large list
> > of attribute groups. These group permissions can be dynamically derived in
> > the callback.
> > 
> > Suggested-by: Greg KH <gregkh@linuxfoundation.org>
> > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > ---
> >  drivers/nvmem/nvmem-sysfs.c | 74 +++++++++----------------------------
> >  1 file changed, 18 insertions(+), 56 deletions(-)
> > 
> > diff --git a/drivers/nvmem/nvmem-sysfs.c b/drivers/nvmem/nvmem-sysfs.c
> > index 8759c4470012..1ff1801048f6 100644
> > --- a/drivers/nvmem/nvmem-sysfs.c
> > +++ b/drivers/nvmem/nvmem-sysfs.c
> > @@ -103,6 +103,17 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
> >  
> >  	return count;
> >  }
> > +static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
> > +					 struct bin_attribute *attr, int i)
> > +{
> > +	struct device *dev = container_of(kobj, struct device, kobj);
> > +	struct nvmem_device *nvmem = to_nvmem_device(dev);
> > +
> > +	if (nvmem->root_only)
> > +		return nvmem->read_only ? 0400 : 0600;
> > +
> > +	return nvmem->read_only ? 0444 : 0644;
> > +}
> Looks like I did a pretty good job as I arrived at a similar result 
> independently. Even added root_only to nvmem_device. You beat me to it. 
> :)
> 
> >  const struct attribute_group **nvmem_sysfs_get_groups(
> >  					struct nvmem_device *nvmem,
> >  					const struct nvmem_config *config)
> >  {
> > -	if (config->root_only)
> > -		return nvmem->read_only ?
> > -			nvmem_ro_root_dev_groups :
> > -			nvmem_rw_root_dev_groups;
> > -
> > -	return nvmem->read_only ? nvmem_ro_dev_groups : nvmem_rw_dev_groups;
> > +	return nvmem_dev_groups;
> >  }
> I was wondering if we can export nvmem_dev_group instead of this 
> nvmem_sysfs_get_groups() to fetch it.
> 
> Also, we need some logic in nvmem_register() to abort if bad combination 
> is given (i.e. root_only set but no reg_read), as returning 0 in 
> is_bin_visible callback does not abort. I can do that in my patch if you 
> want.

Returning 0 will cause the file to not be created at all, which is
probably what you want, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] nvmem: core: use is_bin_visible for permissions
  2020-03-24 17:46   ` Greg KH
@ 2020-03-25  9:15     ` Srinivas Kandagatla
  0 siblings, 0 replies; 10+ messages in thread
From: Srinivas Kandagatla @ 2020-03-25  9:15 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, nicholas.johnson-opensource



On 24/03/2020 17:46, Greg KH wrote:
> On Tue, Mar 24, 2020 at 05:16:00PM +0000, Srinivas Kandagatla wrote:
>> By using is_bin_visible callback to set permissions will remove a large list
>> of attribute groups. These group permissions can be dynamically derived in
>> the callback.
>>
>> Suggested-by: Greg KH <gregkh@linuxfoundation.org>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>   drivers/nvmem/nvmem-sysfs.c | 74 +++++++++----------------------------
>>   1 file changed, 18 insertions(+), 56 deletions(-)
>>
>> diff --git a/drivers/nvmem/nvmem-sysfs.c b/drivers/nvmem/nvmem-sysfs.c
>> index 8759c4470012..1ff1801048f6 100644
>> --- a/drivers/nvmem/nvmem-sysfs.c
>> +++ b/drivers/nvmem/nvmem-sysfs.c
>> @@ -103,6 +103,17 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
>>   
>>   	return count;
>>   }
>> +static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
>> +					 struct bin_attribute *attr, int i)
>> +{
>> +	struct device *dev = container_of(kobj, struct device, kobj);
>> +	struct nvmem_device *nvmem = to_nvmem_device(dev);
>> +
>> +	if (nvmem->root_only)
>> +		return nvmem->read_only ? 0400 : 0600;
>> +
>> +	return nvmem->read_only ? 0444 : 0644;
>> +}
> 
> I don't know why this is so hard for me to read, but how about this
> instead:
> 
> static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
> 					 struct bin_attribute *attr, int i)
> {
> 	struct device *dev = container_of(kobj, struct device, kobj);
> 	struct nvmem_device *nvmem = to_nvmem_device(dev);
> 	umode_t mode = 0400;
> 
> 	if (!nvmem->root_only)
> 		mode |= 0044;
> 
> 	if (!nvmem->read_only)
> 		mode |= 0200;
> 
> 	return mode;
> }
> 
> Did I get the logic corect?

That looks perfect and matches what is in upstream!
Thanks for suggesting this cleanup!

I will send v2 with this change!

--srini
> 
> thanks,
> 
> greg k-h
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] nvmem: core: use is_bin_visible for permissions
  2020-03-24 23:05   ` Nicholas Johnson
  2020-03-25  7:36     ` gregkh
@ 2020-03-25  9:36     ` Srinivas Kandagatla
  1 sibling, 0 replies; 10+ messages in thread
From: Srinivas Kandagatla @ 2020-03-25  9:36 UTC (permalink / raw)
  To: Nicholas Johnson; +Cc: gregkh, linux-kernel



On 24/03/2020 23:05, Nicholas Johnson wrote:
> I was wondering if we can export nvmem_dev_group instead of this
> nvmem_sysfs_get_groups() to fetch it.

Nope, nvmem_sysfs_get_groups() has a dummy stub for not selecting 
CONFIG_NVMEM_SYSFS.

--srini

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-03-25  9:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24 17:15 [PATCH 0/3] nvmem: use is_bin_visible callback Srinivas Kandagatla
2020-03-24 17:15 ` [PATCH 1/3] nvmem: core: use device_register and device_unregister Srinivas Kandagatla
2020-03-24 17:15 ` [PATCH 2/3] nvmem: core: add root_only member to nvmem device struct Srinivas Kandagatla
2020-03-24 17:16 ` [PATCH 3/3] nvmem: core: use is_bin_visible for permissions Srinivas Kandagatla
2020-03-24 17:46   ` Greg KH
2020-03-25  9:15     ` Srinivas Kandagatla
2020-03-24 23:05   ` Nicholas Johnson
2020-03-25  7:36     ` gregkh
2020-03-25  9:36     ` Srinivas Kandagatla
2020-03-24 17:58 ` [PATCH 0/3] nvmem: use is_bin_visible callback Greg KH

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).