mmc: struct device - replace bus_id with dev_name(), dev_set_name()
Subsystems (4)
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 <[email protected]>
Subject: mmc: struct device - replace bus_id with dev_name(), dev_set_name()
---
drivers/mmc/core/bus.c +1 -2
@@ -216,8 +216,7 @@ int mmc_add_card(struct mmc_card *card)int ret;const char *type; -snprintf (card->dev.bus_id,sizeof (card->dev.bus_id), -"%s:%04x" ,mmc_hostname (card->host), card->rca); +dev_set_name (&card->dev,"%s:%04x" ,mmc_hostname (card->host), card->rca);switch (card->type) {case MMC_TYPE_MMC :
drivers/mmc/core/host.c +2 -3
@@ -73,8 +73,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)if (err) goto free; -snprintf (host->class_dev.bus_id,BUS_ID_SIZE , -"mmc%d" , host->index); +dev_set_name (&host->class_dev,"mmc%d" , host->index); host->parent = dev; host->class_dev.parent = dev;
@@ -121,7 +120,7 @@ int mmc_add_host(struct mmc_host *host)WARN_ON ((host->caps &MMC_CAP_SDIO_IRQ ) && !host->ops->enable_sdio_irq); -led_trigger_register_simple (host->class_dev.bus_id, &host->led); +led_trigger_register_simple (dev_name (&host->class_dev), &host->led); err =device_add (&host->class_dev);if (err)
drivers/mmc/core/sdio_bus.c +1 -2
@@ -239,8 +239,7 @@ int sdio_add_func(struct sdio_func *func) {int ret; -snprintf (func->dev.bus_id,sizeof (func->dev.bus_id), -"%s:%d" ,mmc_card_id (func->card), func->num); +dev_set_name (&func->dev,"%s:%d" ,mmc_card_id (func->card), func->num); ret =device_add (&func->dev);if (ret ==0 )
drivers/mmc/host/mmc_spi.c +1 -1
@@ -1348,7 +1348,7 @@ static int mmc_spi_probe(struct spi_device *spi) goto fail_add_host; dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n", - mmc->class_dev.bus_id, + dev_name(&mmc->class_dev), host->dma_dev ? "" : ", no DMA", (host->pdata && host->pdata->get_ro) ? "" : ", no WP",
drivers/mmc/host/sdhci.c +1 -1
@@ -1733,7 +1733,7 @@ int sdhci_add_host(struct sdhci_host *host)mmc_add_host (mmc);printk (KERN_INFO "%s: SDHCI controller on %s [%s] using %s%s\n" , -mmc_hostname (mmc), host->hw_name,mmc_dev (mmc)->bus_id, +mmc_hostname (mmc), host->hw_name,dev_name (mmc_dev (mmc)), (host->flags &SDHCI_USE_ADMA )?"A" :"" , (host->flags &SDHCI_USE_DMA )?"DMA" :"PIO" );
drivers/mmc/host/tifm_sd.c +8 -8
@@ -632,7 +632,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)if (host->req) {printk (KERN_ERR "%s : unfinished request detected\n" , - sock->dev.bus_id); +dev_name (&sock->dev)); mrq->cmd->error = -ETIMEDOUT ; goto err_out; }
@@ -672,7 +672,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE)) {printk (KERN_ERR "%s : scatterlist map failed\n" , - sock->dev.bus_id); +dev_name (&sock->dev)); mrq->cmd->error = -ENOMEM ; goto err_out; }
@@ -684,7 +684,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq) : PCI_DMA_FROMDEVICE);if (host->sg_len <1 ) {printk (KERN_ERR "%s : scatterlist map failed\n" , - sock->dev.bus_id); +dev_name (&sock->dev)); tifm_unmap_sg(sock, &host->bounce_buf, 1, r_data->flags & MMC_DATA_WRITE ? PCI_DMA_TODEVICE
@@ -748,7 +748,7 @@ static void tifm_sd_end_cmd(unsigned long data)if (!mrq) {printk (KERN_ERR " %s : no request to complete?\n" , - sock->dev.bus_id); +dev_name (&sock->dev));spin_unlock_irqrestore (&sock->lock, flags);return ; }
@@ -789,7 +789,7 @@ static void tifm_sd_abort(unsigned long data)printk (KERN_ERR "%s : card failed to respond for a long period of time " "(%x, %x)\n" , - host->dev->dev.bus_id, host->req->cmd->opcode, host->cmd_flags); +dev_name (&host->dev->dev), host->req->cmd->opcode, host->cmd_flags);tifm_eject (host->dev); }
@@ -906,7 +906,7 @@ static int tifm_sd_initialize_host(struct tifm_sd *host)if (rc) {printk (KERN_ERR "%s : controller failed to reset\n" , - sock->dev.bus_id); +dev_name (&sock->dev));return -ENODEV ; }
@@ -933,7 +933,7 @@ static int tifm_sd_initialize_host(struct tifm_sd *host)if (rc) {printk (KERN_ERR "%s : card not ready - probe failed on initialization\n" , - sock->dev.bus_id); +dev_name (&sock->dev));return -ENODEV ; }
@@ -954,7 +954,7 @@ static int tifm_sd_probe(struct tifm_dev *sock)if (!(TIFM_SOCK_STATE_OCCUPIED &readl (sock->addr +SOCK_PRESENT_STATE ))) {printk (KERN_WARNING "%s : card gone, unexpectedly\n" , - sock->dev.bus_id); +dev_name (&sock->dev));return rc; }
include/linux/mmc/card.h +1 -1
@@ -130,7 +130,7 @@ struct mmc_card {#define mmc_card_set_blockaddr (c) ((c)->state |= MMC_STATE_BLOCKADDR)#define mmc_card_name (c) ((c)->cid.prod_name) -#define mmc_card_id (c) ((c)->dev.bus_id) +#define mmc_card_id (c) (dev_name(&(c)->dev))#define mmc_list_to_card (l) container_of(l, struct mmc_card, node)#define mmc_get_drvdata (c) dev_get_drvdata(&(c)->dev)
include/linux/mmc/host.h +1 -1
@@ -176,7 +176,7 @@ static inline void *mmc_priv(struct mmc_host *host)#define mmc_dev (x) ((x)->parent)#define mmc_classdev (x) (&(x)->class_dev) -#define mmc_hostname (x) ((x)->class_dev.bus_id) +#define mmc_hostname (x) (dev_name(&(x)->class_dev))extern int mmc_suspend_host (struct mmc_host *,pm_message_t );extern int mmc_resume_host (struct mmc_host *);
include/linux/mmc/sdio_func.h +1 -1
@@ -63,7 +63,7 @@ struct sdio_func {#define sdio_func_set_present (f) ((f)->state |= SDIO_STATE_PRESENT) -#define sdio_func_id (f) ((f)->dev.bus_id) +#define sdio_func_id (f) (dev_name(&(f)->dev))#define sdio_get_drvdata (f) dev_get_drvdata(&(f)->dev)#define sdio_set_drvdata (f,d) dev_set_drvdata(&(f)->dev, d)
Quoted 32 lines · Kay Sievers
include/linux/mmc/card.h +1
-1@@ -130,7 +130,7 @@ struct mmc_card {#define mmc_card_set_blockaddr (c) ((c)->state |= MMC_STATE_BLOCKADDR)#define mmc_card_name (c) ((c)->cid.prod_name) -#define mmc_card_id (c) ((c)->dev.bus_id) +#define mmc_card_id (c) (dev_name(&(c)->dev))#define mmc_list_to_card (l) container_of(l, struct mmc_card, node)#define mmc_get_drvdata (c) dev_get_drvdata(&(c)->dev)include/linux/mmc/host.h +1
-1@@ -176,7 +176,7 @@ static inline void *mmc_priv(struct mmc_host *host)#define mmc_dev (x) ((x)->parent)#define mmc_classdev (x) (&(x)->class_dev) -#define mmc_hostname (x) ((x)->class_dev.bus_id) +#define mmc_hostname (x) (dev_name(&(x)->class_dev))extern int mmc_suspend_host (struct mmc_host *,pm_message_t );extern int mmc_resume_host (struct mmc_host *);include/linux/mmc/sdio_func.h +0
-0
include/linux/mmc/sdio_func.h struct sdio_func { · line 69
Quoted 8 lines
include/linux/mmc/sdio_func.h +1
-1@@ -63,7 +63,7 @@ struct sdio_func {#define sdio_func_set_present (f) ((f)->state |= SDIO_STATE_PRESENT) -#define sdio_func_id (f) ((f)->dev.bus_id) +#define sdio_func_id (f) (dev_name(&(f)->dev))#define sdio_get_drvdata (f) dev_get_drvdata(&(f)->dev)#define sdio_set_drvdata (f,d) dev_set_drvdata(&(f)->dev, d)
A lot of these helpers don't seem to add that much, would you care for a patch removing them Pierre?
Specifically sdio_func_id, sdio_get/set_drvdata don't have that many users.
mmc_hostname has a lot of users, but if you're agreeable, I could take a crack at that too.
Harvey
Hi Harvey,
Quoted 45 lines
Quoted 33 lines
include/linux/mmc/card.h +1
-1@@ -130,7 +130,7 @@ struct mmc_card {#define mmc_card_set_blockaddr (c) ((c)->state |= MMC_STATE_BLOCKADDR)#define mmc_card_name (c) ((c)->cid.prod_name) -#define mmc_card_id (c) ((c)->dev.bus_id) +#define mmc_card_id (c) (dev_name(&(c)->dev))#define mmc_list_to_card (l) container_of(l, struct mmc_card, node)#define mmc_get_drvdata (c) dev_get_drvdata(&(c)->dev)include/linux/mmc/host.h +1
-1@@ -176,7 +176,7 @@ static inline void *mmc_priv(struct mmc_host *host)#define mmc_dev (x) ((x)->parent)#define mmc_classdev (x) (&(x)->class_dev) -#define mmc_hostname (x) ((x)->class_dev.bus_id) +#define mmc_hostname (x) (dev_name(&(x)->class_dev))extern int mmc_suspend_host (struct mmc_host *,pm_message_t );extern int
mmc_resume_host(struct mmc_host *);include/linux/mmc/sdio_func.h +0
-0include/linux/mmc/sdio_func.h struct sdio_func { · line 69
Quoted 8 lines
include/linux/mmc/sdio_func.h +1
-1@@ -63,7 +63,7 @@ struct sdio_func {#define sdio_func_set_present (f) ((f)->state |= SDIO_STATE_PRESENT) -#define sdio_func_id (f) ((f)->dev.bus_id) +#define sdio_func_id (f) (dev_name(&(f)->dev))#define sdio_get_drvdata (f) dev_get_drvdata(&(f)->dev)#define sdio_set_drvdata (f,d) dev_set_drvdata(&(f)->dev, d)A lot of these helpers don't seem to add that much, would you care for a patch removing them Pierre?
Quoted 2 lines
Specifically
sdio_func_id, sdio_get/set_drvdata don't have that many users.
I prefer if we keep them. Since they take the proper parameter. Otherwise the driver has to always got func->dev for everything. Most SDIO drivers care of the function and not about the struct device underneath it.
Regards
Marcel
Quoted 5 lines · Marcel Holtmann
Hi Harvey,
Quoted 4 lines
A lot of these helpers don't seem to add that much, would you care for a patch removing them Pierre?
Quoted 8 lines
Quoted 2 lines
Specifically
sdio_func_id, sdio_get/set_drvdata don't have that many users.I prefer if we keep them. Since they take the proper parameter. Otherwise the driver has to always got
func->devfor everything. Most SDIO drivers care of the function and not about the struct device underneath it.
Sure, it just seemed odd to have a wrapper around a wrapper.
Cheers,
Harvey
Quoted 10 lines · On Wed, 29 Oct 2008 18:48:04 -0700 Harvey Harrison <[email protected]>…
A lot of these helpers don't seem to add that much, would you care for a patch removing them Pierre?
Specifically
sdio_func_id, sdio_get/set_drvdata don't have that many users.
mmc_hostnamehas a lot of users, but if you're agreeable, I could take a crack at that too.
As Marcel said, they provide a nice abstraction (even if it is indeed a bit silly to have wrappers around wrappers around ..). It also tends to make the code a bit more readable.
Rgds
Signature · 6 lines
-- Pierre Ossman WARNING: This correspondence is being monitored by the Swedish government. Make sure your server uses encryption for SMTP traffic and consider using PGP for end-to-end encryption.
Quoted 7 lines · On Thu, 30 Oct 2008 02:20:00 +0100 Kay Sievers <[email protected]> wrote:
From: Kay Sievers <[email protected]>
Subject: mmc: struct device - replacebus_idwithdev_name(),dev_set_name()Cc Pierre Ossman <[email protected]>Signed-off-by Kay Sievers <[email protected]>---
That patch looks good to me. Are the prerequisites already in Linus' tree so you want me to push this to him as well?
Rgds
Signature · 6 lines
-- Pierre Ossman WARNING: This correspondence is being monitored by the Swedish government. Make sure your server uses encryption for SMTP traffic and consider using PGP for end-to-end encryption.
Quoted 6 lines · Pierre Ossman
Quoted 3 lines · On Thu, 30 Oct 2008 02:20:00 +0100 Kay Sievers <[email protected]> wrote:
From: Kay Sievers <[email protected]>
Subject: mmc: struct device - replacebus_idwithdev_name(),dev_set_name()
Quoted 7 lines
Quoted 4 lines
Cc Pierre Ossman <[email protected]>Signed-off-by Kay Sievers <[email protected]>---
That patch looks good to me. Are the prerequisites already in Linus' tree so you want me to push this to him as well?
Yes, it's all in Linus' tree and also released in .27. Please push it.
Thanks,
Kay