Skip to content

Commit

Permalink
ata: Add and use ata_print_version_once
Browse files Browse the repository at this point in the history
Use a single mechanism to show driver version.
Reduces text a tiny bit too.

Remove uses of static int printed_version
Add and use ata_print_version(const struct device *, const char *ver)
and ata_print_version_once.

$ size drivers/ata/built-in.*
   text	   data	    bss	    dec	    hex	filename
 544969	  73893	 116584	 735446	  b38d6	drivers/ata/built-in.allyesconfig.ata.o
 543870	  73893	 116592	 734355	  b34ad	drivers/ata/built-in.allyesconfig.print_once.o
 141328	  14689	   4220	 160237	  271ed	drivers/ata/built-in.defconfig.ata.o
 141212	  14689	   4220	 160121	  27179	drivers/ata/built-in.defconfig.print_once.o

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Jeff Garzik <[email protected]>
  • Loading branch information
JoePerches authored and jgarzik committed Jul 23, 2011
1 parent a9a79df commit 06296a1
Show file tree
Hide file tree
Showing 43 changed files with 63 additions and 133 deletions.
4 changes: 1 addition & 3 deletions drivers/ata/acard-ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ static int acard_ahci_port_start(struct ata_port *ap)

static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
unsigned int board_id = ent->driver_data;
struct ata_port_info pi = acard_ahci_port_info[board_id];
const struct ata_port_info *ppi[] = { &pi, NULL };
Expand All @@ -416,8 +415,7 @@ static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id

WARN_ON((int)ATA_MAX_QUEUE > AHCI_MAX_CMDS);

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

/* acquire resources */
rc = pcim_enable_device(pdev);
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,6 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)

static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
unsigned int board_id = ent->driver_data;
struct ata_port_info pi = ahci_port_info[board_id];
const struct ata_port_info *ppi[] = { &pi, NULL };
Expand All @@ -1072,8 +1071,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)

WARN_ON((int)ATA_MAX_QUEUE > AHCI_MAX_CMDS);

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

/* The AHCI driver can only drive the SATA ports, the PATA driver
can drive them all so if both drivers are selected make sure
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/ata_piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1562,7 +1562,6 @@ static bool piix_broken_system_poweroff(struct pci_dev *pdev)
static int __devinit piix_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
static int printed_version;
struct device *dev = &pdev->dev;
struct ata_port_info port_info[2];
const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
Expand All @@ -1572,9 +1571,7 @@ static int __devinit piix_init_one(struct pci_dev *pdev,
struct piix_host_priv *hpriv;
int rc;

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

/* no hotplugging support for later devices (FIXME) */
if (!in_module_init && ent->driver_data >= ich5_sata)
Expand Down
6 changes: 6 additions & 0 deletions drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -6647,6 +6647,12 @@ int ata_dev_printk(const struct ata_device *dev, const char *level,
}
EXPORT_SYMBOL(ata_dev_printk);

void ata_print_version(const struct device *dev, const char *version)
{
dev_printk(KERN_DEBUG, dev, "version %s\n", version);
}
EXPORT_SYMBOL(ata_print_version);

/*
* libata is essentially a library of internal helper functions for
* low-level ATA host controller drivers. As such, the API/ABI is
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/pata_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,12 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
}
};
const struct ata_port_info *ppi[] = { NULL, NULL };
static int printed_version;
int type = id->driver_data;
void *hpriv = NULL;
u8 fifo;
int rc;

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

rc = pcim_enable_device(pdev);
if (rc)
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_artop.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ static struct ata_port_operations artop6260_ops = {

static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
{
static int printed_version;
static const struct ata_port_info info_6210 = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
Expand Down Expand Up @@ -378,9 +377,7 @@ static int artop_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
const struct ata_port_info *ppi[] = { NULL, NULL };
int rc;

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

rc = pcim_enable_device(pdev);
if (rc)
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/pata_atp867x.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ static int atp867x_ata_pci_sff_init_host(struct ata_host *host)
static int atp867x_init_one(struct pci_dev *pdev,
const struct pci_device_id *id)
{
static int printed_version;
static const struct ata_port_info info_867x = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
Expand All @@ -499,8 +498,7 @@ static int atp867x_init_one(struct pci_dev *pdev,
const struct ata_port_info *ppi[] = { &info_867x, NULL };
int rc;

if (!printed_version++)
dev_info(&pdev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

rc = pcim_enable_device(pdev);
if (rc)
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_efar.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ static struct ata_port_operations efar_ops = {

static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static const struct ata_port_info info = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
Expand All @@ -273,9 +272,7 @@ static int efar_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
};
const struct ata_port_info *ppi[] = { &info, &info };

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

return ata_pci_bmdma_init_one(pdev, ppi, &efar_sht, NULL,
ATA_HOST_PARALLEL_SCAN);
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/pata_hpt3x3.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ static void hpt3x3_init_chipset(struct pci_dev *dev)

static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
{
static int printed_version;
static const struct ata_port_info info = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
Expand All @@ -206,8 +205,7 @@ static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)

hpt3x3_init_chipset(pdev);

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
if (!host)
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_it8213.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ static struct ata_port_operations it8213_ops = {

static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static const struct ata_port_info info = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
Expand All @@ -269,9 +268,7 @@ static int it8213_init_one (struct pci_dev *pdev, const struct pci_device_id *en
/* Current IT8213 stuff is single port */
const struct ata_port_info *ppi[] = { &info, &ata_dummy_port_info };

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

return ata_pci_bmdma_init_one(pdev, ppi, &it8213_sht, NULL, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/pata_ixp4xx_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)

ixp4xx_setup_port(ap, data, cs0->start, cs1->start);

dev_info(&pdev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

/* activate host */
return ata_host_activate(host, irq, ata_sff_interrupt, 0, &ixp4xx_sht);
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/pata_mpiix.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,13 @@ static struct ata_port_operations mpiix_port_ops = {
static int mpiix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
{
/* Single threaded by the PCI probe logic */
static int printed_version;
struct ata_host *host;
struct ata_port *ap;
void __iomem *cmd_addr, *ctl_addr;
u16 idetim;
int cmd, ctl, irq;

if (!printed_version++)
dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&dev->dev, DRV_VERSION);

host = ata_host_alloc(&dev->dev, 1);
if (!host)
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_netcell.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ static struct ata_port_operations netcell_ops = {

static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static const struct ata_port_info info = {
.flags = ATA_FLAG_SLAVE_POSS,
/* Actually we don't really care about these as the
Expand All @@ -70,9 +69,7 @@ static int netcell_init_one (struct pci_dev *pdev, const struct pci_device_id *e
const struct ata_port_info *port_info[] = { &info, NULL };
int rc;

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

rc = pcim_enable_device(pdev);
if (rc)
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_ns87415.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ static void ns87415_fixup(struct pci_dev *pdev)

static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static const struct ata_port_info info = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
Expand All @@ -370,9 +369,7 @@ static int ns87415_init_one (struct pci_dev *pdev, const struct pci_device_id *e
if (PCI_SLOT(pdev->devfn) == 0x0E)
ppi[0] = &info87560;
#endif
if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

rc = pcim_enable_device(pdev);
if (rc)
Expand Down
6 changes: 4 additions & 2 deletions drivers/ata/pata_octeon_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
irq_handler_t irq_handler = NULL;
void __iomem *base;
struct octeon_cf_port *cf_port;
char version[32];

res_cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);

Expand Down Expand Up @@ -905,10 +906,11 @@ static int __devinit octeon_cf_probe(struct platform_device *pdev)
ata_port_desc(ap, "cmd %p ctl %p", base, ap->ioaddr.ctl_addr);


dev_info(&pdev->dev, "version " DRV_VERSION" %d bit%s.\n",
snprintf(version, sizeof(version), "%s %d bit%s",
DRV_VERSION,
(ocd->is16bit) ? 16 : 8,
(cs1) ? ", True IDE" : "");

ata_print_version_once(&pdev->dev, version);

return ata_host_activate(host, irq, irq_handler, 0, &octeon_cf_sht);

Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_oldpiix.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ static struct ata_port_operations oldpiix_pata_ops = {

static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static const struct ata_port_info info = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
Expand All @@ -244,9 +243,7 @@ static int oldpiix_init_one (struct pci_dev *pdev, const struct pci_device_id *e
};
const struct ata_port_info *ppi[] = { &info, NULL };

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

return ata_pci_bmdma_init_one(pdev, ppi, &oldpiix_sht, NULL, 0);
}
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/pata_opti.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,8 @@ static int opti_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.port_ops = &opti_port_ops
};
const struct ata_port_info *ppi[] = { &info, NULL };
static int printed_version;

if (!printed_version++)
dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&dev->dev, DRV_VERSION);

return ata_pci_sff_init_one(dev, ppi, &opti_sht, NULL, 0);
}
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/pata_optidma.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,9 @@ static int optidma_init_one(struct pci_dev *dev, const struct pci_device_id *id)
.port_ops = &optiplus_port_ops
};
const struct ata_port_info *ppi[] = { &info_82c700, NULL };
static int printed_version;
int rc;

if (!printed_version++)
dev_printk(KERN_DEBUG, &dev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&dev->dev, DRV_VERSION);

rc = pcim_enable_device(dev);
if (rc)
Expand Down
4 changes: 1 addition & 3 deletions drivers/ata/pata_pdc2027x.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base)
*/
static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static const unsigned long cmd_offset[] = { 0x17c0, 0x15c0 };
static const unsigned long bmdma_offset[] = { 0x1000, 0x1008 };
unsigned int board_idx = (unsigned int) ent->driver_data;
Expand All @@ -707,8 +706,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
void __iomem *mmio_base;
int i, rc;

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

/* alloc host */
host = ata_host_alloc_pinfo(&pdev->dev, ppi, 2);
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_radisys.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ static struct ata_port_operations radisys_pata_ops = {

static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
static const struct ata_port_info info = {
.flags = ATA_FLAG_SLAVE_POSS,
.pio_mask = ATA_PIO4,
Expand All @@ -223,9 +222,7 @@ static int radisys_init_one (struct pci_dev *pdev, const struct pci_device_id *e
};
const struct ata_port_info *ppi[] = { &info, NULL };

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

return ata_pci_bmdma_init_one(pdev, ppi, &radisys_sht, NULL, 0);
}
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_rdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ static struct scsi_host_template rdc_sht = {
static int __devinit rdc_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
static int printed_version;
struct device *dev = &pdev->dev;
struct ata_port_info port_info[2];
const struct ata_port_info *ppi[] = { &port_info[0], &port_info[1] };
Expand All @@ -321,9 +320,7 @@ static int __devinit rdc_init_one(struct pci_dev *pdev,
struct rdc_host_priv *hpriv;
int rc;

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

port_info[0] = rdc_port_info;
port_info[1] = rdc_port_info;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/pata_rz1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
};
const struct ata_port_info *ppi[] = { &info, NULL };

printk_once(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

if (rz1000_fifo_disable(pdev) == 0)
return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL, 0);
Expand Down
5 changes: 1 addition & 4 deletions drivers/ata/pata_scc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,15 +1071,12 @@ static int scc_host_init(struct ata_host *host)

static int scc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
static int printed_version;
unsigned int board_idx = (unsigned int) ent->driver_data;
const struct ata_port_info *ppi[] = { &scc_port_info[board_idx], NULL };
struct ata_host *host;
int rc;

if (!printed_version++)
dev_printk(KERN_DEBUG, &pdev->dev,
"version " DRV_VERSION "\n");
ata_print_version_once(&pdev->dev, DRV_VERSION);

host = ata_host_alloc_pinfo(&pdev->dev, ppi, 1);
if (!host)
Expand Down
Loading

0 comments on commit 06296a1

Please sign in to comment.