mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Srinivas Kandagatla <srini@kernel.org>
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
	Kees Cook <kees@kernel.org>, Kees Cook <kees+treewide@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: linux-next: manual merge of the nvmem tree with the origin tree
Date: Wed, 2 Dec 2026 14:01:13 +0000	[thread overview]
Message-ID: <axAkqae_LOoKRJjO@sirena.org.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 6501 bytes --]

Hi all,

Today's linux-next merge of the nvmem tree got a conflict in:

  drivers/nvmem/core.c

between commit:

  4dd10fbbeb9c3 ("treewide: Convert devm_kmalloc() family to the devm_kmalloc_obj() family")

from the origin tree and commit:

  96139b973a2a5 ("nvmem: don't use devres in subsystem code")

from the nvmem tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

diff --combined drivers/nvmem/core.c
index fe9b8a3a5ea02,b5af34e523b67..0000000000000
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@@ -184,24 -184,25 +184,25 @@@ static struct lock_class_key eeprom_loc
  #endif
  
  static ssize_t type_show(struct device *dev,
- 			 struct device_attribute *attr, char *buf)
+ 			 const struct device_attribute *attr, char *buf)
  {
  	struct nvmem_device *nvmem = to_nvmem_device(dev);
  
  	return sysfs_emit(buf, "%s\n", nvmem_type_str[nvmem->type]);
  }
  
- static DEVICE_ATTR_RO(type);
+ static const DEVICE_ATTR_RO(type);
  
- static ssize_t force_ro_show(struct device *dev, struct device_attribute *attr,
- 			     char *buf)
+ static ssize_t force_ro_show(struct device *dev,
+ 			     const struct device_attribute *attr, char *buf)
  {
  	struct nvmem_device *nvmem = to_nvmem_device(dev);
  
  	return sysfs_emit(buf, "%d\n", nvmem->read_only);
  }
  
- static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr,
+ static ssize_t force_ro_store(struct device *dev,
+ 			      const struct device_attribute *attr,
  			      const char *buf, size_t count)
  {
  	struct nvmem_device *nvmem = to_nvmem_device(dev);
@@@ -213,9 -214,9 +214,9 @@@
  	return count;
  }
  
- static DEVICE_ATTR_RW(force_ro);
+ static const DEVICE_ATTR_RW(force_ro);
  
- static struct attribute *nvmem_attrs[] = {
+ static const struct attribute *const nvmem_attrs[] = {
  	&dev_attr_force_ro.attr,
  	&dev_attr_type.attr,
  	NULL,
@@@ -334,7 -335,7 +335,7 @@@ static size_t nvmem_bin_attr_size(struc
  }
  
  static umode_t nvmem_attr_is_visible(struct kobject *kobj,
- 				     struct attribute *attr, int i)
+ 				     const struct attribute *attr, int i)
  {
  	struct device *dev = kobj_to_dev(kobj);
  	struct nvmem_device *nvmem = to_nvmem_device(dev);
@@@ -412,10 -413,10 +413,10 @@@ static const struct bin_attribute *cons
  
  static const struct attribute_group nvmem_bin_group = {
  	.bin_attrs	= nvmem_bin_attributes,
- 	.attrs		= nvmem_attrs,
+ 	.attrs_const	= nvmem_attrs,
  	.is_bin_visible = nvmem_bin_attr_is_visible,
  	.bin_size	= nvmem_bin_attr_size,
- 	.is_visible	= nvmem_attr_is_visible,
+ 	.is_visible_const = nvmem_attr_is_visible,
  };
  
  static const struct attribute_group *nvmem_dev_groups[] = {
@@@ -478,12 -479,7 +479,7 @@@ static void nvmem_sysfs_remove_compat(s
  
  static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem)
  {
- 	struct attribute_group group = {
- 		.name	= "cells",
- 	};
  	struct nvmem_cell_entry *entry;
- 	const struct bin_attribute **pattrs;
- 	struct bin_attribute *attrs;
  	unsigned int ncells = 0, i = 0;
  	int ret;
  
@@@ -494,43 -490,72 +490,72 @@@
  
  	/* Allocate an array of attributes with a sentinel */
  	ncells = list_count_nodes(&nvmem->cells);
- 	pattrs = devm_kzalloc_objs(&nvmem->dev, *pattrs, ncells + 1);
+ 
+ 	const struct bin_attribute **pattrs __free(kfree) = kzalloc_objs(*pattrs, ncells + 1);
  	if (!pattrs)
  		return -ENOMEM;
  
- 	attrs = devm_kzalloc_objs(&nvmem->dev, struct bin_attribute, ncells);
+ 	struct bin_attribute *attrs __free(kfree) = kzalloc_objs(*attrs, ncells);
  	if (!attrs)
  		return -ENOMEM;
  
  	/* Initialize each attribute to take the name and size of the cell */
  	list_for_each_entry(entry, &nvmem->cells, node) {
  		sysfs_bin_attr_init(&attrs[i]);
- 		attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL,
- 						    "%s@%x,%x", entry->name,
- 						    entry->offset,
- 						    entry->bit_offset);
+ 		attrs[i].attr.name = kasprintf(GFP_KERNEL, "%s@%x,%x", entry->name,
+ 					       entry->offset, entry->bit_offset);
+ 		if (!attrs[i].attr.name) {
+ 			list_for_each_entry_continue_reverse(entry, &nvmem->cells, node)
+ 				kfree(attrs[--i].attr.name);
+ 			return -ENOMEM;
+ 		}
+ 
  		attrs[i].attr.mode = 0444 & nvmem_bin_attr_get_umode(nvmem);
  		attrs[i].size = entry->bytes;
  		attrs[i].read = &nvmem_cell_attr_read;
  		attrs[i].private = entry;
- 		if (!attrs[i].attr.name)
- 			return -ENOMEM;
  
  		pattrs[i] = &attrs[i];
  		i++;
  	}
  
- 	group.bin_attrs = pattrs;
+ 	memset(&nvmem->sysfs_group, 0, sizeof(nvmem->sysfs_group));
+ 	nvmem->sysfs_group.name = "cells";
+ 	nvmem->sysfs_group.bin_attrs = pattrs;
  
- 	ret = device_add_group(&nvmem->dev, &group);
- 	if (ret)
+ 	ret = device_add_group(&nvmem->dev, &nvmem->sysfs_group);
+ 	if (ret) {
+ 		i = 0;
+ 		list_for_each_entry(entry, &nvmem->cells, node)
+ 			kfree(attrs[i++].attr.name);
  		return ret;
+ 	}
  
  	nvmem->sysfs_cells_populated = true;
+ 	nvmem->sysfs_attrs = no_free_ptr(attrs);
+ 	nvmem->sysfs_pattrs = no_free_ptr(pattrs);
  
  	return ret;
  }
  
+ static void nvmem_sysfs_remove_cells(struct nvmem_device *nvmem)
+ {
+ 	int i;
+ 
+ 	if (!nvmem->sysfs_cells_populated)
+ 		return;
+ 
+ 	device_remove_group(&nvmem->dev, &nvmem->sysfs_group);
+ 
+ 	for (i = 0; nvmem->sysfs_pattrs[i]; i++)
+ 		kfree(nvmem->sysfs_pattrs[i]->attr.name);
+ 
+ 	kfree(nvmem->sysfs_attrs);
+ 	kfree(nvmem->sysfs_pattrs);
+ 
+ 	nvmem->sysfs_cells_populated = false;
+ }
+ 
  #else /* CONFIG_NVMEM_SYSFS */
  
  static int nvmem_sysfs_setup_compat(struct nvmem_device *nvmem,
@@@ -541,6 -566,9 +566,9 @@@
  static void nvmem_sysfs_remove_compat(struct nvmem_device *nvmem)
  {
  }
+ static void nvmem_sysfs_remove_cells(struct nvmem_device *nvmem)
+ {
+ }
  
  #endif /* CONFIG_NVMEM_SYSFS */
  
@@@ -1115,6 -1143,8 +1143,8 @@@ void nvmem_unregister(struct nvmem_devi
  
  	nvmem_sysfs_remove_compat(nvmem);
  	nvmem_destroy_layout(nvmem);
+ 	nvmem_sysfs_remove_cells(nvmem);
+ 	kfree(ops);
  
  	device_unregister(&nvmem->dev);
  }

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

                 reply	other threads:[~2026-12-02 14:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=axAkqae_LOoKRJjO@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=bartosz.golaszewski@oss.qualcomm.com \
    --cc=kees+treewide@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=srini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®