* [PATCH 0/2] eeprom: ee1004: Let device core handle attribute eeprom
@ 2021-05-19 16:32 Heiner Kallweit
2021-05-19 16:33 ` [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS Heiner Kallweit
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Heiner Kallweit @ 2021-05-19 16:32 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Rafael J. Wysocki
Cc: Linux Kernel Mailing List
Instead of creating/removing the attribute ourselves, just declare the
attribute and let the device core handle it. This allows to simplify
the code.
Heiner Kallweit (2):
sysfs: Add helper BIN_ATTRIBUTE_GROUPS
eeprom: ee1004: Let device core handle attribute eeprom
drivers/misc/eeprom/ee1004.c | 26 +++++++++-----------------
include/linux/sysfs.h | 6 ++++++
2 files changed, 15 insertions(+), 17 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS
2021-05-19 16:32 [PATCH 0/2] eeprom: ee1004: Let device core handle attribute eeprom Heiner Kallweit
@ 2021-05-19 16:33 ` Heiner Kallweit
2021-05-19 17:04 ` Greg Kroah-Hartman
2021-05-19 16:34 ` [PATCH 2/2] eeprom: ee1004: Let device core handle attribute eeprom Heiner Kallweit
2021-05-20 19:25 ` [PATCH v2] " Heiner Kallweit
2 siblings, 1 reply; 10+ messages in thread
From: Heiner Kallweit @ 2021-05-19 16:33 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Rafael J. Wysocki
Cc: Linux Kernel Mailing List
New helper BIN_ATTRIBUTE_GROUPS() does the same as ATTRIBUTE_GROUPS(),
just for binary attributes.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
include/linux/sysfs.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index d76a1ddf8..a12556a4b 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -162,6 +162,12 @@ static const struct attribute_group _name##_group = { \
}; \
__ATTRIBUTE_GROUPS(_name)
+#define BIN_ATTRIBUTE_GROUPS(_name) \
+static const struct attribute_group _name##_group = { \
+ .bin_attrs = _name##_attrs, \
+}; \
+__ATTRIBUTE_GROUPS(_name)
+
struct file;
struct vm_area_struct;
struct address_space;
--
2.31.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] eeprom: ee1004: Let device core handle attribute eeprom
2021-05-19 16:32 [PATCH 0/2] eeprom: ee1004: Let device core handle attribute eeprom Heiner Kallweit
2021-05-19 16:33 ` [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS Heiner Kallweit
@ 2021-05-19 16:34 ` Heiner Kallweit
2021-05-20 19:25 ` [PATCH v2] " Heiner Kallweit
2 siblings, 0 replies; 10+ messages in thread
From: Heiner Kallweit @ 2021-05-19 16:34 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Rafael J. Wysocki
Cc: Linux Kernel Mailing List
Instead of creating/removing the attribute ourselves, just declare the
attribute and let the device core handle it. This allows to simplify
the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/misc/eeprom/ee1004.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/misc/eeprom/ee1004.c b/drivers/misc/eeprom/ee1004.c
index 252e15ba6..0950d4d9d 100644
--- a/drivers/misc/eeprom/ee1004.c
+++ b/drivers/misc/eeprom/ee1004.c
@@ -89,7 +89,7 @@ static ssize_t ee1004_eeprom_read(struct i2c_client *client, char *buf,
return status;
}
-static ssize_t ee1004_read(struct file *filp, struct kobject *kobj,
+static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
@@ -160,15 +160,15 @@ static ssize_t ee1004_read(struct file *filp, struct kobject *kobj,
return requested;
}
-static const struct bin_attribute eeprom_attr = {
- .attr = {
- .name = "eeprom",
- .mode = 0444,
- },
- .size = EE1004_EEPROM_SIZE,
- .read = ee1004_read,
+static BIN_ATTR_RO(eeprom, EE1004_EEPROM_SIZE);
+
+static struct bin_attribute *ee1004_attrs[] = {
+ &bin_attr_eeprom,
+ NULL
};
+BIN_ATTRIBUTE_GROUPS(ee1004);
+
static int ee1004_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -222,11 +222,6 @@ static int ee1004_probe(struct i2c_client *client,
ee1004_current_page);
mutex_unlock(&ee1004_bus_lock);
- /* Create the sysfs eeprom file */
- err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr);
- if (err)
- goto err_clients_lock;
-
dev_info(&client->dev,
"%u byte EE1004-compliant SPD EEPROM, read-only\n",
EE1004_EEPROM_SIZE);
@@ -237,8 +232,6 @@ static int ee1004_probe(struct i2c_client *client,
return 0;
- err_clients_lock:
- mutex_lock(&ee1004_bus_lock);
err_clients:
if (--ee1004_dev_count == 0) {
for (cnr--; cnr >= 0; cnr--) {
@@ -255,8 +248,6 @@ static int ee1004_remove(struct i2c_client *client)
{
int i;
- sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
-
/* Remove page select clients if this is the last device */
mutex_lock(&ee1004_bus_lock);
if (--ee1004_dev_count == 0) {
@@ -275,6 +266,7 @@ static int ee1004_remove(struct i2c_client *client)
static struct i2c_driver ee1004_driver = {
.driver = {
.name = "ee1004",
+ .dev_groups = ee1004_groups,
},
.probe = ee1004_probe,
.remove = ee1004_remove,
--
2.31.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS
2021-05-19 16:33 ` [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS Heiner Kallweit
@ 2021-05-19 17:04 ` Greg Kroah-Hartman
2021-05-19 19:02 ` Heiner Kallweit
0 siblings, 1 reply; 10+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-19 17:04 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Arnd Bergmann, Rafael J. Wysocki, Linux Kernel Mailing List
On Wed, May 19, 2021 at 06:33:14PM +0200, Heiner Kallweit wrote:
> New helper BIN_ATTRIBUTE_GROUPS() does the same as ATTRIBUTE_GROUPS(),
> just for binary attributes.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> include/linux/sysfs.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> index d76a1ddf8..a12556a4b 100644
> --- a/include/linux/sysfs.h
> +++ b/include/linux/sysfs.h
> @@ -162,6 +162,12 @@ static const struct attribute_group _name##_group = { \
> }; \
> __ATTRIBUTE_GROUPS(_name)
>
> +#define BIN_ATTRIBUTE_GROUPS(_name) \
> +static const struct attribute_group _name##_group = { \
> + .bin_attrs = _name##_attrs, \
> +}; \
> +__ATTRIBUTE_GROUPS(_name)
Is this really needed by more than just 1 driver?
How about just "open code" this for now, binary sysfs files are rare.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS
2021-05-19 17:04 ` Greg Kroah-Hartman
@ 2021-05-19 19:02 ` Heiner Kallweit
2021-05-21 18:41 ` Greg Kroah-Hartman
0 siblings, 1 reply; 10+ messages in thread
From: Heiner Kallweit @ 2021-05-19 19:02 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Arnd Bergmann, Rafael J. Wysocki, Linux Kernel Mailing List
On 19.05.2021 19:04, Greg Kroah-Hartman wrote:
> On Wed, May 19, 2021 at 06:33:14PM +0200, Heiner Kallweit wrote:
>> New helper BIN_ATTRIBUTE_GROUPS() does the same as ATTRIBUTE_GROUPS(),
>> just for binary attributes.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>> include/linux/sysfs.h | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
>> index d76a1ddf8..a12556a4b 100644
>> --- a/include/linux/sysfs.h
>> +++ b/include/linux/sysfs.h
>> @@ -162,6 +162,12 @@ static const struct attribute_group _name##_group = { \
>> }; \
>> __ATTRIBUTE_GROUPS(_name)
>>
>> +#define BIN_ATTRIBUTE_GROUPS(_name) \
>> +static const struct attribute_group _name##_group = { \
>> + .bin_attrs = _name##_attrs, \
>> +}; \
>> +__ATTRIBUTE_GROUPS(_name)
>
> Is this really needed by more than just 1 driver?
>
Few more use case I saw:
devcd_dev_groups in drivers/base/devcoredump.c
w1_f3a_group in drivers/w1/slaves/w1_ds2413.c
w1_slave_default_groups in drivers/w1/w1.c
> How about just "open code" this for now, binary sysfs files are rare.
>
> thanks,
>
> greg k-h
>
Heiner
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] eeprom: ee1004: Let device core handle attribute eeprom
2021-05-19 16:32 [PATCH 0/2] eeprom: ee1004: Let device core handle attribute eeprom Heiner Kallweit
2021-05-19 16:33 ` [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS Heiner Kallweit
2021-05-19 16:34 ` [PATCH 2/2] eeprom: ee1004: Let device core handle attribute eeprom Heiner Kallweit
@ 2021-05-20 19:25 ` Heiner Kallweit
2021-05-21 18:43 ` Heiner Kallweit
2 siblings, 1 reply; 10+ messages in thread
From: Heiner Kallweit @ 2021-05-20 19:25 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman, Rafael J. Wysocki
Cc: Linux Kernel Mailing List
Instead of creating/removing the attribute ourselves, just declare the
attribute and let the device core handle it. This allows to simplify
the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- open-code the proposed BIN_ATTRIBUTES_GROUPS macro
I leave it to you which version you prefer.
---
drivers/misc/eeprom/ee1004.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/misc/eeprom/ee1004.c b/drivers/misc/eeprom/ee1004.c
index 252e15ba6..d61acdaba 100644
--- a/drivers/misc/eeprom/ee1004.c
+++ b/drivers/misc/eeprom/ee1004.c
@@ -89,7 +89,7 @@ static ssize_t ee1004_eeprom_read(struct i2c_client *client, char *buf,
return status;
}
-static ssize_t ee1004_read(struct file *filp, struct kobject *kobj,
+static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
@@ -160,15 +160,19 @@ static ssize_t ee1004_read(struct file *filp, struct kobject *kobj,
return requested;
}
-static const struct bin_attribute eeprom_attr = {
- .attr = {
- .name = "eeprom",
- .mode = 0444,
- },
- .size = EE1004_EEPROM_SIZE,
- .read = ee1004_read,
+static BIN_ATTR_RO(eeprom, EE1004_EEPROM_SIZE);
+
+static struct bin_attribute *ee1004_attrs[] = {
+ &bin_attr_eeprom,
+ NULL
+};
+
+static const struct attribute_group ee1004_group = {
+ .bin_attrs = ee1004_attrs,
};
+__ATTRIBUTE_GROUPS(ee1004);
+
static int ee1004_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -222,11 +226,6 @@ static int ee1004_probe(struct i2c_client *client,
ee1004_current_page);
mutex_unlock(&ee1004_bus_lock);
- /* Create the sysfs eeprom file */
- err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr);
- if (err)
- goto err_clients_lock;
-
dev_info(&client->dev,
"%u byte EE1004-compliant SPD EEPROM, read-only\n",
EE1004_EEPROM_SIZE);
@@ -237,8 +236,6 @@ static int ee1004_probe(struct i2c_client *client,
return 0;
- err_clients_lock:
- mutex_lock(&ee1004_bus_lock);
err_clients:
if (--ee1004_dev_count == 0) {
for (cnr--; cnr >= 0; cnr--) {
@@ -255,8 +252,6 @@ static int ee1004_remove(struct i2c_client *client)
{
int i;
- sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
-
/* Remove page select clients if this is the last device */
mutex_lock(&ee1004_bus_lock);
if (--ee1004_dev_count == 0) {
@@ -275,6 +270,7 @@ static int ee1004_remove(struct i2c_client *client)
static struct i2c_driver ee1004_driver = {
.driver = {
.name = "ee1004",
+ .dev_groups = ee1004_groups,
},
.probe = ee1004_probe,
.remove = ee1004_remove,
--
2.31.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS
2021-05-19 19:02 ` Heiner Kallweit
@ 2021-05-21 18:41 ` Greg Kroah-Hartman
2021-05-21 18:41 ` Greg Kroah-Hartman
0 siblings, 1 reply; 10+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-21 18:41 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Arnd Bergmann, Rafael J. Wysocki, Linux Kernel Mailing List
On Wed, May 19, 2021 at 09:02:47PM +0200, Heiner Kallweit wrote:
> On 19.05.2021 19:04, Greg Kroah-Hartman wrote:
> > On Wed, May 19, 2021 at 06:33:14PM +0200, Heiner Kallweit wrote:
> >> New helper BIN_ATTRIBUTE_GROUPS() does the same as ATTRIBUTE_GROUPS(),
> >> just for binary attributes.
> >>
> >> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> >> ---
> >> include/linux/sysfs.h | 6 ++++++
> >> 1 file changed, 6 insertions(+)
> >>
> >> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> >> index d76a1ddf8..a12556a4b 100644
> >> --- a/include/linux/sysfs.h
> >> +++ b/include/linux/sysfs.h
> >> @@ -162,6 +162,12 @@ static const struct attribute_group _name##_group = { \
> >> }; \
> >> __ATTRIBUTE_GROUPS(_name)
> >>
> >> +#define BIN_ATTRIBUTE_GROUPS(_name) \
> >> +static const struct attribute_group _name##_group = { \
> >> + .bin_attrs = _name##_attrs, \
> >> +}; \
> >> +__ATTRIBUTE_GROUPS(_name)
> >
> > Is this really needed by more than just 1 driver?
> >
> Few more use case I saw:
> devcd_dev_groups in drivers/base/devcoredump.c
> w1_f3a_group in drivers/w1/slaves/w1_ds2413.c
> w1_slave_default_groups in drivers/w1/w1.c
Ok, might as well, can't hurt to add this :)
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS
2021-05-21 18:41 ` Greg Kroah-Hartman
@ 2021-05-21 18:41 ` Greg Kroah-Hartman
2021-05-21 18:45 ` Heiner Kallweit
0 siblings, 1 reply; 10+ messages in thread
From: Greg Kroah-Hartman @ 2021-05-21 18:41 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Arnd Bergmann, Rafael J. Wysocki, Linux Kernel Mailing List
On Fri, May 21, 2021 at 08:41:28PM +0200, Greg Kroah-Hartman wrote:
> On Wed, May 19, 2021 at 09:02:47PM +0200, Heiner Kallweit wrote:
> > On 19.05.2021 19:04, Greg Kroah-Hartman wrote:
> > > On Wed, May 19, 2021 at 06:33:14PM +0200, Heiner Kallweit wrote:
> > >> New helper BIN_ATTRIBUTE_GROUPS() does the same as ATTRIBUTE_GROUPS(),
> > >> just for binary attributes.
> > >>
> > >> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> > >> ---
> > >> include/linux/sysfs.h | 6 ++++++
> > >> 1 file changed, 6 insertions(+)
> > >>
> > >> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> > >> index d76a1ddf8..a12556a4b 100644
> > >> --- a/include/linux/sysfs.h
> > >> +++ b/include/linux/sysfs.h
> > >> @@ -162,6 +162,12 @@ static const struct attribute_group _name##_group = { \
> > >> }; \
> > >> __ATTRIBUTE_GROUPS(_name)
> > >>
> > >> +#define BIN_ATTRIBUTE_GROUPS(_name) \
> > >> +static const struct attribute_group _name##_group = { \
> > >> + .bin_attrs = _name##_attrs, \
> > >> +}; \
> > >> +__ATTRIBUTE_GROUPS(_name)
> > >
> > > Is this really needed by more than just 1 driver?
> > >
> > Few more use case I saw:
> > devcd_dev_groups in drivers/base/devcoredump.c
> > w1_f3a_group in drivers/w1/slaves/w1_ds2413.c
> > w1_slave_default_groups in drivers/w1/w1.c
>
> Ok, might as well, can't hurt to add this :)
>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Oh wait, I'm the maintainer of the other file that uses this, I'll take
both of these then :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] eeprom: ee1004: Let device core handle attribute eeprom
2021-05-20 19:25 ` [PATCH v2] " Heiner Kallweit
@ 2021-05-21 18:43 ` Heiner Kallweit
0 siblings, 0 replies; 10+ messages in thread
From: Heiner Kallweit @ 2021-05-21 18:43 UTC (permalink / raw)
To: Arnd Bergmann, Rafael J. Wysocki
Cc: Linux Kernel Mailing List, Greg Kroah-Hartman
Greg added his Reviewed-by to v1, so you may disregard v2.
On 20.05.2021 21:25, Heiner Kallweit wrote:
> Instead of creating/removing the attribute ourselves, just declare the
> attribute and let the device core handle it. This allows to simplify
> the code.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
> v2:
> - open-code the proposed BIN_ATTRIBUTES_GROUPS macro
> I leave it to you which version you prefer.
> ---
> drivers/misc/eeprom/ee1004.c | 30 +++++++++++++-----------------
> 1 file changed, 13 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/misc/eeprom/ee1004.c b/drivers/misc/eeprom/ee1004.c
> index 252e15ba6..d61acdaba 100644
> --- a/drivers/misc/eeprom/ee1004.c
> +++ b/drivers/misc/eeprom/ee1004.c
> @@ -89,7 +89,7 @@ static ssize_t ee1004_eeprom_read(struct i2c_client *client, char *buf,
> return status;
> }
>
> -static ssize_t ee1004_read(struct file *filp, struct kobject *kobj,
> +static ssize_t eeprom_read(struct file *filp, struct kobject *kobj,
> struct bin_attribute *bin_attr,
> char *buf, loff_t off, size_t count)
> {
> @@ -160,15 +160,19 @@ static ssize_t ee1004_read(struct file *filp, struct kobject *kobj,
> return requested;
> }
>
> -static const struct bin_attribute eeprom_attr = {
> - .attr = {
> - .name = "eeprom",
> - .mode = 0444,
> - },
> - .size = EE1004_EEPROM_SIZE,
> - .read = ee1004_read,
> +static BIN_ATTR_RO(eeprom, EE1004_EEPROM_SIZE);
> +
> +static struct bin_attribute *ee1004_attrs[] = {
> + &bin_attr_eeprom,
> + NULL
> +};
> +
> +static const struct attribute_group ee1004_group = {
> + .bin_attrs = ee1004_attrs,
> };
>
> +__ATTRIBUTE_GROUPS(ee1004);
> +
> static int ee1004_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -222,11 +226,6 @@ static int ee1004_probe(struct i2c_client *client,
> ee1004_current_page);
> mutex_unlock(&ee1004_bus_lock);
>
> - /* Create the sysfs eeprom file */
> - err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr);
> - if (err)
> - goto err_clients_lock;
> -
> dev_info(&client->dev,
> "%u byte EE1004-compliant SPD EEPROM, read-only\n",
> EE1004_EEPROM_SIZE);
> @@ -237,8 +236,6 @@ static int ee1004_probe(struct i2c_client *client,
>
> return 0;
>
> - err_clients_lock:
> - mutex_lock(&ee1004_bus_lock);
> err_clients:
> if (--ee1004_dev_count == 0) {
> for (cnr--; cnr >= 0; cnr--) {
> @@ -255,8 +252,6 @@ static int ee1004_remove(struct i2c_client *client)
> {
> int i;
>
> - sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
> -
> /* Remove page select clients if this is the last device */
> mutex_lock(&ee1004_bus_lock);
> if (--ee1004_dev_count == 0) {
> @@ -275,6 +270,7 @@ static int ee1004_remove(struct i2c_client *client)
> static struct i2c_driver ee1004_driver = {
> .driver = {
> .name = "ee1004",
> + .dev_groups = ee1004_groups,
> },
> .probe = ee1004_probe,
> .remove = ee1004_remove,
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS
2021-05-21 18:41 ` Greg Kroah-Hartman
@ 2021-05-21 18:45 ` Heiner Kallweit
0 siblings, 0 replies; 10+ messages in thread
From: Heiner Kallweit @ 2021-05-21 18:45 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Arnd Bergmann, Rafael J. Wysocki, Linux Kernel Mailing List
On 21.05.2021 20:41, Greg Kroah-Hartman wrote:
> On Fri, May 21, 2021 at 08:41:28PM +0200, Greg Kroah-Hartman wrote:
>> On Wed, May 19, 2021 at 09:02:47PM +0200, Heiner Kallweit wrote:
>>> On 19.05.2021 19:04, Greg Kroah-Hartman wrote:
>>>> On Wed, May 19, 2021 at 06:33:14PM +0200, Heiner Kallweit wrote:
>>>>> New helper BIN_ATTRIBUTE_GROUPS() does the same as ATTRIBUTE_GROUPS(),
>>>>> just for binary attributes.
>>>>>
>>>>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>>>>> ---
>>>>> include/linux/sysfs.h | 6 ++++++
>>>>> 1 file changed, 6 insertions(+)
>>>>>
>>>>> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
>>>>> index d76a1ddf8..a12556a4b 100644
>>>>> --- a/include/linux/sysfs.h
>>>>> +++ b/include/linux/sysfs.h
>>>>> @@ -162,6 +162,12 @@ static const struct attribute_group _name##_group = { \
>>>>> }; \
>>>>> __ATTRIBUTE_GROUPS(_name)
>>>>>
>>>>> +#define BIN_ATTRIBUTE_GROUPS(_name) \
>>>>> +static const struct attribute_group _name##_group = { \
>>>>> + .bin_attrs = _name##_attrs, \
>>>>> +}; \
>>>>> +__ATTRIBUTE_GROUPS(_name)
>>>>
>>>> Is this really needed by more than just 1 driver?
>>>>
>>> Few more use case I saw:
>>> devcd_dev_groups in drivers/base/devcoredump.c
>>> w1_f3a_group in drivers/w1/slaves/w1_ds2413.c
>>> w1_slave_default_groups in drivers/w1/w1.c
>>
>> Ok, might as well, can't hurt to add this :)
>>
>> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> Oh wait, I'm the maintainer of the other file that uses this, I'll take
> both of these then :)
>
Even better, thanks!
> thanks,
>
> greg k-h
>
Heiner
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-05-21 18:45 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 16:32 [PATCH 0/2] eeprom: ee1004: Let device core handle attribute eeprom Heiner Kallweit
2021-05-19 16:33 ` [PATCH 1/2] sysfs: Add helper BIN_ATTRIBUTE_GROUPS Heiner Kallweit
2021-05-19 17:04 ` Greg Kroah-Hartman
2021-05-19 19:02 ` Heiner Kallweit
2021-05-21 18:41 ` Greg Kroah-Hartman
2021-05-21 18:41 ` Greg Kroah-Hartman
2021-05-21 18:45 ` Heiner Kallweit
2021-05-19 16:34 ` [PATCH 2/2] eeprom: ee1004: Let device core handle attribute eeprom Heiner Kallweit
2021-05-20 19:25 ` [PATCH v2] " Heiner Kallweit
2021-05-21 18:43 ` Heiner Kallweit
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.