LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* ieee1394: struct device - replace bus_id with dev_name(), dev_set_name()
@ 2008-10-30  0:49 Kay Sievers
  2008-10-31  7:55 ` Stefan Richter
  0 siblings, 1 reply; 2+ messages in thread
From: Kay Sievers @ 2008-10-30  0:49 UTC (permalink / raw)
  To: Stefan Richter; +Cc: linux-kernel, Greg KH

This patch is part of a larger patch series which will remove
the "char bus_id[20]" name string from struct device. The device
name is managed in the kobject anyway, and without any size
limitation, and just needlessly copied into "struct device".

To set and read the device name dev_name(dev) and dev_set_name(dev)
must be used. If your code uses static kobjects, which it shouldn't
do, "const char *init_name" can be used to statically provide the
name the registered device should have. At registration time, the
init_name field is cleared, to enforce the use of dev_name(dev) to
access the device name at a later time.

We need to get rid of all occurrences of bus_id in the entire tree
to be able to enable the new interface. Please apply this patch,
and possibly convert any remaining remaining occurrences of bus_id.

We want to submit a patch to -next, which will remove bus_id from
"struct device", to find the remaining pieces to convert, and finally
switch over to the new api, which will remove the 20 bytes array
and does no longer have a size limitation.

Thanks,
Kay


From: Kay Sievers <kay.sievers@vrfy.org>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Subject: ieee1394: struct device - replace bus_id with dev_name(), dev_set_name()

CC: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-Off-By: Kay Sievers <kay.sievers@vrfy.org>
---


diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index 8dd09d8..237d0c9 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -155,11 +155,11 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
 	memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device));
 	h->device.parent = dev;
 	set_dev_node(&h->device, dev_to_node(dev));
-	snprintf(h->device.bus_id, BUS_ID_SIZE, "fw-host%d", h->id);
+	dev_set_name(&h->device, "fw-host%d", h->id);
 
 	h->host_dev.parent = &h->device;
 	h->host_dev.class = &hpsb_host_class;
-	snprintf(h->host_dev.bus_id, BUS_ID_SIZE, "fw-host%d", h->id);
+	dev_set_name(&h->host_dev, "fw-host%d", h->id);
 
 	if (device_register(&h->device))
 		goto fail;
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 2376b72..9e39f73 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -826,13 +826,11 @@ static struct node_entry *nodemgr_create_node(octlet_t guid,
 	memcpy(&ne->device, &nodemgr_dev_template_ne,
 	       sizeof(ne->device));
 	ne->device.parent = &host->device;
-	snprintf(ne->device.bus_id, BUS_ID_SIZE, "%016Lx",
-		 (unsigned long long)(ne->guid));
+	dev_set_name(&ne->device, "%016Lx", (unsigned long long)(ne->guid));
 
 	ne->node_dev.parent = &ne->device;
 	ne->node_dev.class = &nodemgr_ne_class;
-	snprintf(ne->node_dev.bus_id, BUS_ID_SIZE, "%016Lx",
-		(unsigned long long)(ne->guid));
+	dev_set_name(&ne->node_dev, "%016Lx", (unsigned long long)(ne->guid));
 
 	if (device_register(&ne->device))
 		goto fail_devreg;
@@ -932,13 +930,11 @@ static void nodemgr_register_device(struct node_entry *ne,
 
 	ud->device.parent = parent;
 
-	snprintf(ud->device.bus_id, BUS_ID_SIZE, "%s-%u",
-		 ne->device.bus_id, ud->id);
+	dev_set_name(&ud->device, "%s-%u", dev_name(&ne->device), ud->id);
 
 	ud->unit_dev.parent = &ud->device;
 	ud->unit_dev.class = &nodemgr_ud_class;
-	snprintf(ud->unit_dev.bus_id, BUS_ID_SIZE, "%s-%u",
-		 ne->device.bus_id, ud->id);
+	dev_set_name(&ud->unit_dev, "%s-%u", dev_name(&ne->device), ud->id);
 
 	if (device_register(&ud->device))
 		goto fail_devreg;
@@ -953,7 +949,7 @@ static void nodemgr_register_device(struct node_entry *ne,
 fail_classdevreg:
 	device_unregister(&ud->device);
 fail_devreg:
-	HPSB_ERR("Failed to create unit %s", ud->device.bus_id);
+	HPSB_ERR("Failed to create unit %s", dev_name(&ud->device));
 }	
 
 


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

* Re: ieee1394: struct device - replace bus_id with dev_name(), dev_set_name()
  2008-10-30  0:49 ieee1394: struct device - replace bus_id with dev_name(), dev_set_name() Kay Sievers
@ 2008-10-31  7:55 ` Stefan Richter
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Richter @ 2008-10-31  7:55 UTC (permalink / raw)
  To: Kay Sievers; +Cc: linux-kernel, Greg KH, linux1394-devel

Kay Sievers wrote:
> This patch is part of a larger patch series which will remove
> the "char bus_id[20]" name string from struct device. The device
> name is managed in the kobject anyway, and without any size
> limitation, and just needlessly copied into "struct device".
> 
> To set and read the device name dev_name(dev) and dev_set_name(dev)
> must be used. If your code uses static kobjects, which it shouldn't
> do, "const char *init_name" can be used to statically provide the
> name the registered device should have. At registration time, the
> init_name field is cleared, to enforce the use of dev_name(dev) to
> access the device name at a later time.
> 
> We need to get rid of all occurrences of bus_id in the entire tree
> to be able to enable the new interface. Please apply this patch,
> and possibly convert any remaining remaining occurrences of bus_id.
> 
> We want to submit a patch to -next, which will remove bus_id from
> "struct device", to find the remaining pieces to convert, and finally
> switch over to the new api, which will remove the 20 bytes array
> and does no longer have a size limitation.
> 
> Thanks,
> Kay
> 
> 
> From: Kay Sievers <kay.sievers@vrfy.org>
> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
> Subject: ieee1394: struct device - replace bus_id with dev_name(), dev_set_name()
> 
> CC: Stefan Richter <stefanr@s5r6.in-berlin.de>
> Signed-Off-By: Kay Sievers <kay.sievers@vrfy.org>
> ---

Committed to linux1394-2.6.git.  Thanks.

> 
> 
> diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
> index 8dd09d8..237d0c9 100644
> --- a/drivers/ieee1394/hosts.c
> +++ b/drivers/ieee1394/hosts.c
> @@ -155,11 +155,11 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
>  	memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device));
>  	h->device.parent = dev;
>  	set_dev_node(&h->device, dev_to_node(dev));
> -	snprintf(h->device.bus_id, BUS_ID_SIZE, "fw-host%d", h->id);
> +	dev_set_name(&h->device, "fw-host%d", h->id);
>  
>  	h->host_dev.parent = &h->device;
>  	h->host_dev.class = &hpsb_host_class;
> -	snprintf(h->host_dev.bus_id, BUS_ID_SIZE, "fw-host%d", h->id);
> +	dev_set_name(&h->host_dev, "fw-host%d", h->id);
>  
>  	if (device_register(&h->device))
>  		goto fail;
> diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
> index 2376b72..9e39f73 100644
> --- a/drivers/ieee1394/nodemgr.c
> +++ b/drivers/ieee1394/nodemgr.c
> @@ -826,13 +826,11 @@ static struct node_entry *nodemgr_create_node(octlet_t guid,
>  	memcpy(&ne->device, &nodemgr_dev_template_ne,
>  	       sizeof(ne->device));
>  	ne->device.parent = &host->device;
> -	snprintf(ne->device.bus_id, BUS_ID_SIZE, "%016Lx",
> -		 (unsigned long long)(ne->guid));
> +	dev_set_name(&ne->device, "%016Lx", (unsigned long long)(ne->guid));
>  
>  	ne->node_dev.parent = &ne->device;
>  	ne->node_dev.class = &nodemgr_ne_class;
> -	snprintf(ne->node_dev.bus_id, BUS_ID_SIZE, "%016Lx",
> -		(unsigned long long)(ne->guid));
> +	dev_set_name(&ne->node_dev, "%016Lx", (unsigned long long)(ne->guid));
>  
>  	if (device_register(&ne->device))
>  		goto fail_devreg;
> @@ -932,13 +930,11 @@ static void nodemgr_register_device(struct node_entry *ne,
>  
>  	ud->device.parent = parent;
>  
> -	snprintf(ud->device.bus_id, BUS_ID_SIZE, "%s-%u",
> -		 ne->device.bus_id, ud->id);
> +	dev_set_name(&ud->device, "%s-%u", dev_name(&ne->device), ud->id);
>  
>  	ud->unit_dev.parent = &ud->device;
>  	ud->unit_dev.class = &nodemgr_ud_class;
> -	snprintf(ud->unit_dev.bus_id, BUS_ID_SIZE, "%s-%u",
> -		 ne->device.bus_id, ud->id);
> +	dev_set_name(&ud->unit_dev, "%s-%u", dev_name(&ne->device), ud->id);
>  
>  	if (device_register(&ud->device))
>  		goto fail_devreg;
> @@ -953,7 +949,7 @@ static void nodemgr_register_device(struct node_entry *ne,
>  fail_classdevreg:
>  	device_unregister(&ud->device);
>  fail_devreg:
> -	HPSB_ERR("Failed to create unit %s", ud->device.bus_id);
> +	HPSB_ERR("Failed to create unit %s", dev_name(&ud->device));
>  }	
>  
>  
> 


-- 
Stefan Richter
-=====-==--- =-=- =====
http://arcgraph.de/sr/

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

end of thread, other threads:[~2008-10-31  7:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-30  0:49 ieee1394: struct device - replace bus_id with dev_name(), dev_set_name() Kay Sievers
2008-10-31  7:55 ` Stefan Richter

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