driver: Attach info callback to device, not to driver
Since the info is device specific and not driver specific, attach the callback to the device. This makes it possible to have a info callback for a device which does not have a driver attached. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
4a4f2f20b8
commit
73b0d228e5
|
@ -77,6 +77,9 @@ static int hf_probe(struct device_d *dev)
|
|||
priv->cdev.size = hf->size;
|
||||
priv->cdev.ops = &hf_fops;
|
||||
priv->cdev.priv = hf;
|
||||
|
||||
dev->info = hf_info;
|
||||
|
||||
#ifdef CONFIG_FS_DEVFS
|
||||
devfs_create(&priv->cdev);
|
||||
#endif
|
||||
|
@ -87,7 +90,6 @@ static int hf_probe(struct device_d *dev)
|
|||
static struct driver_d hf_drv = {
|
||||
.name = "hostfile",
|
||||
.probe = hf_probe,
|
||||
.info = hf_info,
|
||||
};
|
||||
device_platform_driver(hf_drv);
|
||||
|
||||
|
@ -111,4 +113,3 @@ int barebox_register_filedev(struct hf_platform_data *hf)
|
|||
|
||||
return sandbox_add_device(dev);
|
||||
}
|
||||
|
||||
|
|
|
@ -635,6 +635,7 @@ static int ahci_probe(struct device_d *dev)
|
|||
ahci->dev = dev;
|
||||
ahci->mmio_base = regs;
|
||||
dev->priv = ahci;
|
||||
dev->info = ahci_info;
|
||||
|
||||
ret = ahci_add_host(ahci);
|
||||
if (ret)
|
||||
|
@ -654,7 +655,6 @@ static __maybe_unused struct of_device_id ahci_dt_ids[] = {
|
|||
static struct driver_d ahci_driver = {
|
||||
.name = "ahci",
|
||||
.probe = ahci_probe,
|
||||
.info = ahci_info,
|
||||
.of_compatible = DRV_OF_COMPAT(ahci_dt_ids),
|
||||
};
|
||||
device_platform_driver(ahci_driver);
|
||||
|
|
|
@ -107,6 +107,7 @@ static int imx_sata_probe(struct device_d *dev)
|
|||
|
||||
imx_ahci->ahci.dev = dev;
|
||||
dev->priv = &imx_ahci->ahci;
|
||||
dev->info = ahci_info,
|
||||
|
||||
ret = ahci_add_host(&imx_ahci->ahci);
|
||||
if (ret)
|
||||
|
@ -143,7 +144,6 @@ static struct platform_device_id imx_sata_ids[] = {
|
|||
static struct driver_d imx_sata_driver = {
|
||||
.name = "imx-sata",
|
||||
.probe = imx_sata_probe,
|
||||
.info = ahci_info,
|
||||
.id_table = imx_sata_ids,
|
||||
};
|
||||
device_platform_driver(imx_sata_driver);
|
||||
|
|
|
@ -201,15 +201,6 @@ struct driver_d *get_driver_by_name(const char *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void noinfo(struct device_d *dev)
|
||||
{
|
||||
printf("no info available for %s\n", dev_name(dev));
|
||||
}
|
||||
|
||||
static void noshortinfo(struct device_d *dev)
|
||||
{
|
||||
}
|
||||
|
||||
int register_driver(struct driver_d *drv)
|
||||
{
|
||||
struct device_d *dev = NULL;
|
||||
|
@ -221,11 +212,6 @@ int register_driver(struct driver_d *drv)
|
|||
list_add_tail(&drv->list, &driver_list);
|
||||
list_add_tail(&drv->bus_list, &drv->bus->driver_list);
|
||||
|
||||
if (!drv->info)
|
||||
drv->info = noinfo;
|
||||
if (!drv->shortinfo)
|
||||
drv->shortinfo = noshortinfo;
|
||||
|
||||
bus_for_each_device(drv->bus, dev)
|
||||
match(drv, dev);
|
||||
|
||||
|
@ -489,8 +475,8 @@ static int do_devinfo(int argc, char *argv[])
|
|||
printf("bus: %s\n\n", dev->bus ?
|
||||
dev->bus->name : "none");
|
||||
|
||||
if (dev->driver)
|
||||
dev->driver->info(dev);
|
||||
if (dev->info)
|
||||
dev->info(dev);
|
||||
|
||||
printf("%s\n", list_empty(&dev->parameters) ?
|
||||
"no parameters available" : "Parameters:");
|
||||
|
|
|
@ -470,7 +470,6 @@ static int atmci_request(struct mci_host *mci, struct mci_cmd *cmd, struct mci_d
|
|||
return atmci_cmd_done(host, stat);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
static void atmci_info(struct device_d *mci_dev)
|
||||
{
|
||||
struct atmel_mci *host = mci_dev->priv;
|
||||
|
@ -493,7 +492,6 @@ static void atmci_info(struct device_d *mci_dev)
|
|||
gpio_is_valid(pd->detect_pin) ? "yes" : "no");
|
||||
|
||||
}
|
||||
#endif /* CONFIG_MCI_INFO */
|
||||
/*
|
||||
* HSMCI (High Speed MCI) module is not fully compatible with MCI module.
|
||||
* HSMCI provides DMA support and a new config register but no more supports
|
||||
|
@ -603,6 +601,9 @@ static int atmci_probe(struct device_d *hw_dev)
|
|||
else
|
||||
host->sdc_reg = ATMCI_SDCSEL_SLOT_A;
|
||||
|
||||
if (IS_ENABLED(CONFIG_MCI_INFO))
|
||||
hw_dev->info = atmci_info;
|
||||
|
||||
mci_register(&host->mci);
|
||||
|
||||
return 0;
|
||||
|
@ -617,8 +618,5 @@ err_gpio_cd_request:
|
|||
static struct driver_d atmci_driver = {
|
||||
.name = "atmel_mci",
|
||||
.probe = atmci_probe,
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
.info = atmci_info,
|
||||
#endif
|
||||
};
|
||||
device_platform_driver(atmci_driver);
|
||||
|
|
|
@ -1282,7 +1282,6 @@ static int mci_sd_read(struct block_device *blk, void *buffer, int block,
|
|||
|
||||
/* ------------------ attach to the device API --------------------------- */
|
||||
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
/**
|
||||
* Extract the Manufacturer ID from the CID
|
||||
* @param mci Instance data
|
||||
|
@ -1408,7 +1407,6 @@ static void mci_info(struct device_d *mci_dev)
|
|||
printf(" Manufacturing date: %u.%u\n", extract_mtd_month(mci),
|
||||
extract_mtd_year(mci));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check if the MCI card is already probed
|
||||
|
@ -1617,6 +1615,9 @@ static int mci_probe(struct device_d *mci_dev)
|
|||
goto on_error;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_MCI_INFO))
|
||||
mci_dev->info = mci_info;
|
||||
|
||||
#ifdef CONFIG_MCI_STARTUP
|
||||
/* if enabled, probe the attached card immediately */
|
||||
mci_card_probe(mci);
|
||||
|
@ -1632,9 +1633,6 @@ on_error:
|
|||
static struct driver_d mci_driver = {
|
||||
.name = "mci",
|
||||
.probe = mci_probe,
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
.info = mci_info,
|
||||
#endif
|
||||
};
|
||||
|
||||
static int mci_init(void)
|
||||
|
|
|
@ -536,7 +536,6 @@ static void mxs_mci_set_ios(struct mci_host *host, struct mci_ios *ios)
|
|||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
const unsigned char bus_width[3] = { 1, 4, 8 };
|
||||
|
||||
static void mxs_mci_info(struct device_d *hw_dev)
|
||||
|
@ -550,7 +549,6 @@ static void mxs_mci_info(struct device_d *hw_dev)
|
|||
printf(" Bus width: %u bit\n", bus_width[mxs_mci->bus_width]);
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static int mxs_mci_probe(struct device_d *hw_dev)
|
||||
{
|
||||
|
@ -617,10 +615,11 @@ static int mxs_mci_probe(struct device_d *hw_dev)
|
|||
host->f_max, mxs_mci_get_unit_clock(mxs_mci) / 2 / 1);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
mxs_mci->f_min = host->f_min;
|
||||
mxs_mci->f_max = host->f_max;
|
||||
#endif
|
||||
if (IS_ENABLED(CONFIG_MCI_INFO)) {
|
||||
mxs_mci->f_min = host->f_min;
|
||||
mxs_mci->f_max = host->f_max;
|
||||
hw_dev->info = mxs_mci_info;
|
||||
}
|
||||
|
||||
return mci_register(host);
|
||||
}
|
||||
|
@ -628,8 +627,5 @@ static int mxs_mci_probe(struct device_d *hw_dev)
|
|||
static struct driver_d mxs_mci_driver = {
|
||||
.name = "mxs_mci",
|
||||
.probe = mxs_mci_probe,
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
.info = mxs_mci_info,
|
||||
#endif
|
||||
};
|
||||
device_platform_driver(mxs_mci_driver);
|
||||
|
|
|
@ -700,7 +700,6 @@ static void mci_set_ios(struct mci_host *host, struct mci_ios *ios)
|
|||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
static void s3c_info(struct device_d *hw_dev)
|
||||
{
|
||||
struct s3c_mci_host *host = hw_dev->priv;
|
||||
|
@ -720,7 +719,6 @@ static void s3c_info(struct device_d *hw_dev)
|
|||
printf("\n Card detection support: %s\n",
|
||||
pd->gpio_detect != 0 ? "yes" : "no");
|
||||
}
|
||||
#endif
|
||||
|
||||
static int s3c_mci_probe(struct device_d *hw_dev)
|
||||
{
|
||||
|
@ -751,6 +749,9 @@ static int s3c_mci_probe(struct device_d *hw_dev)
|
|||
s3c_host->host.f_min = pd->f_min == 0 ? s3c_get_pclk() / 256 : pd->f_min;
|
||||
s3c_host->host.f_max = pd->f_max == 0 ? s3c_get_pclk() / 2 : pd->f_max;
|
||||
|
||||
if (IS_ENABLED(iCONFIG_MCI_INFO))
|
||||
hw_dev->info = s3c_info;
|
||||
|
||||
/*
|
||||
* Start the clock to let the engine and the card finishes its startup
|
||||
*/
|
||||
|
@ -763,8 +764,5 @@ static int s3c_mci_probe(struct device_d *hw_dev)
|
|||
static struct driver_d s3c_mci_driver = {
|
||||
.name = "s3c_mci",
|
||||
.probe = s3c_mci_probe,
|
||||
#ifdef CONFIG_MCI_INFO
|
||||
.info = s3c_info,
|
||||
#endif
|
||||
};
|
||||
device_platform_driver(s3c_mci_driver);
|
||||
|
|
|
@ -269,6 +269,25 @@ static struct file_operations jtag_operations = {
|
|||
.ioctl = jtag_ioctl,
|
||||
};
|
||||
|
||||
static void jtag_info(struct device_d *pdev)
|
||||
{
|
||||
int dn, ret;
|
||||
struct jtag_rd_id jid;
|
||||
struct jtag_info *info = pdev->priv;
|
||||
|
||||
printf(" JTAG:\n");
|
||||
printf(" Devices found: %d\n", info->devices);
|
||||
for (dn = 0; dn < info->devices; dn++) {
|
||||
jid.device = dn;
|
||||
ret = jtag_ioctl(&info->cdev, JTAG_GET_ID, &jid);
|
||||
printf(" Device number: %d\n", dn);
|
||||
if (ret == -1)
|
||||
printf(" JTAG_GET_ID failed: %s\n", strerror(errno));
|
||||
else
|
||||
printf(" ID: 0x%lX\n", jid.id);
|
||||
}
|
||||
}
|
||||
|
||||
static int jtag_probe(struct device_d *pdev)
|
||||
{
|
||||
int i, ret;
|
||||
|
@ -323,6 +342,7 @@ static int jtag_probe(struct device_d *pdev)
|
|||
info->devices = i;
|
||||
info->pdata = pdata;
|
||||
pdev->priv = info;
|
||||
pdev->info = jtag_info;
|
||||
|
||||
info->cdev.name = JTAG_NAME;
|
||||
info->cdev.dev = pdev;
|
||||
|
@ -341,25 +361,6 @@ fail_devfs_create:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void jtag_info(struct device_d *pdev)
|
||||
{
|
||||
int dn, ret;
|
||||
struct jtag_rd_id jid;
|
||||
struct jtag_info *info = pdev->priv;
|
||||
|
||||
printf(" JTAG:\n");
|
||||
printf(" Devices found: %d\n", info->devices);
|
||||
for (dn = 0; dn < info->devices; dn++) {
|
||||
jid.device = dn;
|
||||
ret = jtag_ioctl(&info->cdev, JTAG_GET_ID, &jid);
|
||||
printf(" Device number: %d\n", dn);
|
||||
if (ret == -1)
|
||||
printf(" JTAG_GET_ID failed: %s\n", strerror(errno));
|
||||
else
|
||||
printf(" ID: 0x%lX\n", jid.id);
|
||||
}
|
||||
}
|
||||
|
||||
static void jtag_remove(struct device_d *pdev)
|
||||
{
|
||||
struct jtag_info *info = (struct jtag_info *) pdev->priv;
|
||||
|
@ -374,7 +375,6 @@ static struct driver_d jtag_driver = {
|
|||
.name = JTAG_NAME,
|
||||
.probe = jtag_probe,
|
||||
.remove = jtag_remove,
|
||||
.info = jtag_info,
|
||||
};
|
||||
device_platform_driver(jtag_driver);
|
||||
|
||||
|
|
|
@ -972,6 +972,8 @@ static int cfi_probe (struct device_d *dev)
|
|||
dev_info(dev, "found cfi flash at %p, size %ld\n",
|
||||
info->base, info->size);
|
||||
|
||||
dev->info = cfi_info;
|
||||
|
||||
cfi_init_mtd(info);
|
||||
|
||||
return 0;
|
||||
|
@ -988,7 +990,6 @@ static __maybe_unused struct of_device_id cfi_dt_ids[] = {
|
|||
static struct driver_d cfi_driver = {
|
||||
.name = "cfi_flash",
|
||||
.probe = cfi_probe,
|
||||
.info = cfi_info,
|
||||
.of_compatible = DRV_OF_COMPAT(cfi_dt_ids),
|
||||
};
|
||||
device_platform_driver(cfi_driver);
|
||||
|
|
|
@ -459,6 +459,8 @@ static int cs8900_probe(struct device_d *dev)
|
|||
edev->set_ethaddr = cs8900_set_ethaddr;
|
||||
edev->parent = dev;
|
||||
|
||||
dev->info = cs8900_info;
|
||||
|
||||
eth_register(edev);
|
||||
return 0;
|
||||
}
|
||||
|
@ -466,6 +468,5 @@ static int cs8900_probe(struct device_d *dev)
|
|||
static struct driver_d cs8900_driver = {
|
||||
.name = "cs8900",
|
||||
.probe = cs8900_probe,
|
||||
.info = cs8900_info,
|
||||
};
|
||||
device_platform_driver(cs8900_driver);
|
||||
|
|
|
@ -144,7 +144,6 @@ static void fb_info(struct device_d *dev)
|
|||
|
||||
static struct driver_d fb_driver = {
|
||||
.name = "fb",
|
||||
.info = fb_info,
|
||||
};
|
||||
|
||||
static int fb_match(struct device_d *dev, struct driver_d *drv)
|
||||
|
@ -165,6 +164,8 @@ static int fb_probe(struct device_d *dev)
|
|||
dev_set_param(dev, "mode_name", info->mode_list[0].name);
|
||||
}
|
||||
|
||||
dev->info = fb_info;
|
||||
|
||||
return devfs_create(&info->cdev);
|
||||
}
|
||||
|
||||
|
|
|
@ -321,7 +321,6 @@ static int s3cfb_activate_var(struct fb_info *fb_info)
|
|||
* Print some information about the current hardware state
|
||||
* @param hw_dev S3C video device
|
||||
*/
|
||||
#ifdef CONFIG_DRIVER_VIDEO_S3C_VERBOSE
|
||||
static void s3cfb_info(struct device_d *hw_dev)
|
||||
{
|
||||
uint32_t con1, addr1, addr2, addr3;
|
||||
|
@ -340,7 +339,6 @@ static void s3cfb_info(struct device_d *hw_dev)
|
|||
printf(" Virtual screen offset size: %u half words\n", GET_OFFSIZE(addr3));
|
||||
printf(" Virtual screen page width: %u half words\n", GET_PAGE_WIDTH(addr3));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* There is only one video hardware instance available.
|
||||
|
@ -390,6 +388,9 @@ static int s3cfb_probe(struct device_d *hw_dev)
|
|||
fbi.passive_display = pdata->passive_display;
|
||||
fbi.enable = pdata->enable;
|
||||
|
||||
if (IS_ENABLED(CONFIG_DRIVER_VIDEO_S3C_VERBOSE))
|
||||
hw_dev->info = s3cfb_info;
|
||||
|
||||
ret = register_framebuffer(&fbi.info);
|
||||
if (ret != 0) {
|
||||
dev_err(hw_dev, "Failed to register framebuffer\n");
|
||||
|
@ -402,9 +403,6 @@ static int s3cfb_probe(struct device_d *hw_dev)
|
|||
static struct driver_d s3cfb_driver = {
|
||||
.name = "s3c_fb",
|
||||
.probe = s3cfb_probe,
|
||||
#ifdef CONFIG_DRIVER_VIDEO_S3C_VERBOSE
|
||||
.info = s3cfb_info,
|
||||
#endif
|
||||
};
|
||||
device_platform_driver(s3cfb_driver);
|
||||
|
||||
|
|
|
@ -502,6 +502,8 @@ static int stmfb_probe(struct device_d *hw_dev)
|
|||
else
|
||||
fbi.info.bits_per_pixel = 16;
|
||||
|
||||
hw_dev->info = stmfb_info;
|
||||
|
||||
ret = register_framebuffer(&fbi.info);
|
||||
if (ret != 0) {
|
||||
dev_err(hw_dev, "Failed to register framebuffer\n");
|
||||
|
@ -514,7 +516,6 @@ static int stmfb_probe(struct device_d *hw_dev)
|
|||
static struct driver_d stmfb_driver = {
|
||||
.name = "stmfb",
|
||||
.probe = stmfb_probe,
|
||||
.info = stmfb_info,
|
||||
};
|
||||
device_platform_driver(stmfb_driver);
|
||||
|
||||
|
|
|
@ -107,6 +107,8 @@ struct device_d {
|
|||
struct device_node *device_node;
|
||||
|
||||
struct of_device_id *of_id_entry;
|
||||
|
||||
void (*info) (struct device_d *);
|
||||
};
|
||||
|
||||
/** @brief Describes a driver present in the system */
|
||||
|
@ -124,9 +126,6 @@ struct driver_d {
|
|||
/*! Called if an instance of a device is gone. */
|
||||
void (*remove)(struct device_d *);
|
||||
|
||||
void (*info) (struct device_d *);
|
||||
void (*shortinfo) (struct device_d *);
|
||||
|
||||
struct bus_type *bus;
|
||||
|
||||
struct platform_device_id *id_table;
|
||||
|
|
Loading…
Reference in New Issue