mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-06 07:55:28 -04:00
staging: axis-fifo: use unique identifiers in device names
Axis-fifo devices use physical addresses in their name, for example 'axis_fifo_0x43c00000'. This is generally frowned upon and it does not follow the usual naming scheme that uses unique identifiers. Therefore, use ida_alloc()/ida_free() to implement unique identifiers for axis-fifo device names (i.e. axis_fifo0, axis_fifo1, etc.). Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com> Link: https://lore.kernel.org/r/20250811085417.2641674-2-ovidiu.panait.oss@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
6e5187d82d
commit
e5b264e0a2
@@ -107,6 +107,8 @@
|
||||
static long read_timeout = 1000; /* ms to wait before read() times out */
|
||||
static long write_timeout = 1000; /* ms to wait before write() times out */
|
||||
|
||||
static DEFINE_IDA(axis_fifo_ida);
|
||||
|
||||
/* ----------------------------
|
||||
* module command-line arguments
|
||||
* ----------------------------
|
||||
@@ -123,6 +125,7 @@ MODULE_PARM_DESC(write_timeout, "ms to wait before blocking write() timing out;
|
||||
*/
|
||||
|
||||
struct axis_fifo {
|
||||
int id;
|
||||
int irq; /* interrupt */
|
||||
void __iomem *base_addr; /* kernel space memory */
|
||||
|
||||
@@ -698,10 +701,6 @@ static int axis_fifo_probe(struct platform_device *pdev)
|
||||
|
||||
dev_dbg(fifo->dt_device, "remapped memory to 0x%p\n", fifo->base_addr);
|
||||
|
||||
/* create unique device name */
|
||||
snprintf(device_name, 32, "%s_%pa", DRIVER_NAME, &r_mem->start);
|
||||
dev_dbg(fifo->dt_device, "device name [%s]\n", device_name);
|
||||
|
||||
/* ----------------------------
|
||||
* init IP
|
||||
* ----------------------------
|
||||
@@ -737,6 +736,11 @@ static int axis_fifo_probe(struct platform_device *pdev)
|
||||
* init char device
|
||||
* ----------------------------
|
||||
*/
|
||||
fifo->id = ida_alloc(&axis_fifo_ida, GFP_KERNEL);
|
||||
if (fifo->id < 0)
|
||||
return fifo->id;
|
||||
|
||||
snprintf(device_name, 32, "%s%d", DRIVER_NAME, fifo->id);
|
||||
|
||||
/* create character device */
|
||||
fifo->miscdev.fops = &fops;
|
||||
@@ -744,8 +748,10 @@ static int axis_fifo_probe(struct platform_device *pdev)
|
||||
fifo->miscdev.name = device_name;
|
||||
fifo->miscdev.parent = dev;
|
||||
rc = misc_register(&fifo->miscdev);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
ida_free(&axis_fifo_ida, fifo->id);
|
||||
return rc;
|
||||
}
|
||||
|
||||
axis_fifo_debugfs_init(fifo);
|
||||
|
||||
@@ -759,6 +765,7 @@ static void axis_fifo_remove(struct platform_device *pdev)
|
||||
|
||||
debugfs_remove(fifo->debugfs_dir);
|
||||
misc_deregister(&fifo->miscdev);
|
||||
ida_free(&axis_fifo_ida, fifo->id);
|
||||
}
|
||||
|
||||
static const struct of_device_id axis_fifo_of_match[] = {
|
||||
@@ -798,6 +805,7 @@ module_init(axis_fifo_init);
|
||||
static void __exit axis_fifo_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&axis_fifo_driver);
|
||||
ida_destroy(&axis_fifo_ida);
|
||||
}
|
||||
|
||||
module_exit(axis_fifo_exit);
|
||||
|
||||
Reference in New Issue
Block a user