[3/7] drivers/extcon: add local variable for newly allocated attribute_group**
Commit Message
This allows the compiler to keep the pointer in a register and
prepares for making the struct field "const".
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
drivers/extcon/extcon.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
Comments
On Mon, Oct 09, 2023 at 06:57:36PM +0200, Max Kellermann wrote:
> This allows the compiler to keep the pointer in a register and
> prepares for making the struct field "const".
Again, registers have nothing to do with this.
thanks,
greg k-h
@@ -1202,6 +1202,7 @@ static int extcon_alloc_muex(struct extcon_dev *edev)
*/
static int extcon_alloc_groups(struct extcon_dev *edev)
{
+ const struct attribute_group **groups;
int index;
if (!edev)
@@ -1210,20 +1211,20 @@ static int extcon_alloc_groups(struct extcon_dev *edev)
if (!edev->max_supported)
return 0;
- edev->extcon_dev_type.groups = kcalloc(edev->max_supported + 2,
- sizeof(*edev->extcon_dev_type.groups),
+ edev->extcon_dev_type.groups = groups = kcalloc(edev->max_supported + 2,
+ sizeof(*groups),
GFP_KERNEL);
- if (!edev->extcon_dev_type.groups)
+ if (!groups)
return -ENOMEM;
edev->extcon_dev_type.name = dev_name(&edev->dev);
edev->extcon_dev_type.release = dummy_sysfs_dev_release;
for (index = 0; index < edev->max_supported; index++)
- edev->extcon_dev_type.groups[index] = &edev->cables[index].attr_g;
+ groups[index] = &edev->cables[index].attr_g;
if (edev->mutually_exclusive)
- edev->extcon_dev_type.groups[index] = &edev->attr_g_muex;
+ groups[index] = &edev->attr_g_muex;
edev->dev.type = &edev->extcon_dev_type;