Skip to content

Commit

Permalink
libata: make sff_irq_on() method optional
Browse files Browse the repository at this point in the history
Now, with the introduction of the sff_set_devctl() method, we can
use it in sff_irq_on() method too -- that way its implementations
in 'pata_bf54x' and 'pata_scc' become virtually identical to
ata_sff_irq_on().  The sff_irq_on() method now becomes quite
superfluous, and the only reason not to remove it completely is
the existence of the 'pata_octeon_cf' driver which implements it
as an empty function. Just make the method optional then, with
ata_sff_irq_on() becoming generic taskfile-bound function, still
global for the 'pata_bf54x' driver to be able to call it from its
thaw() and postreset() methods.

While at it, make the sff_irq_on() method and ata_sff_irq_on() return
'void' as the result is always ignored anyway.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
  • Loading branch information
Sergei Shtylyov authored and Jeff Garzik committed May 14, 2010
1 parent 41dec29 commit e42a542
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 66 deletions.
26 changes: 15 additions & 11 deletions drivers/ata/libata-sff.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const struct ata_port_operations ata_sff_port_ops = {
.sff_tf_read = ata_sff_tf_read,
.sff_exec_command = ata_sff_exec_command,
.sff_data_xfer = ata_sff_data_xfer,
.sff_irq_on = ata_sff_irq_on,
.sff_irq_clear = ata_sff_irq_clear,

.lost_interrupt = ata_sff_lost_interrupt,
Expand Down Expand Up @@ -538,24 +537,29 @@ void ata_dev_select(struct ata_port *ap, unsigned int device,
* Enable interrupts on a legacy IDE device using MMIO or PIO,
* wait for idle, clear any pending interrupts.
*
* Note: may NOT be used as the sff_irq_on() entry in
* ata_port_operations.
*
* LOCKING:
* Inherited from caller.
*/
u8 ata_sff_irq_on(struct ata_port *ap)
void ata_sff_irq_on(struct ata_port *ap)
{
struct ata_ioports *ioaddr = &ap->ioaddr;
u8 tmp;

if (ap->ops->sff_irq_on) {
ap->ops->sff_irq_on(ap);
return;
}

ap->ctl &= ~ATA_NIEN;
ap->last_ctl = ap->ctl;

if (ioaddr->ctl_addr)
iowrite8(ap->ctl, ioaddr->ctl_addr);
tmp = ata_wait_idle(ap);
if (ap->ops->sff_set_devctl || ioaddr->ctl_addr)
ata_sff_set_devctl(ap, ap->ctl);
ata_wait_idle(ap);

ap->ops->sff_irq_clear(ap);

return tmp;
}
EXPORT_SYMBOL_GPL(ata_sff_irq_on);

Expand Down Expand Up @@ -1186,7 +1190,7 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
qc = ata_qc_from_tag(ap, qc->tag);
if (qc) {
if (likely(!(qc->err_mask & AC_ERR_HSM))) {
ap->ops->sff_irq_on(ap);
ata_sff_irq_on(ap);
ata_qc_complete(qc);
} else
ata_port_freeze(ap);
Expand All @@ -1202,7 +1206,7 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
} else {
if (in_wq) {
spin_lock_irqsave(ap->lock, flags);
ap->ops->sff_irq_on(ap);
ata_sff_irq_on(ap);
ata_qc_complete(qc);
spin_unlock_irqrestore(ap->lock, flags);
} else
Expand Down Expand Up @@ -1946,7 +1950,7 @@ void ata_sff_thaw(struct ata_port *ap)
/* clear & re-enable interrupts */
ap->ops->sff_check_status(ap);
ap->ops->sff_irq_clear(ap);
ap->ops->sff_irq_on(ap);
ata_sff_irq_on(ap);
}
EXPORT_SYMBOL_GPL(ata_sff_thaw);

Expand Down
29 changes: 2 additions & 27 deletions drivers/ata/pata_bf54x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1227,30 +1227,6 @@ static void bfin_irq_clear(struct ata_port *ap)
| MULTI_TERM_INT | UDMAIN_TERM_INT | UDMAOUT_TERM_INT);
}

/**
* bfin_irq_on - Enable interrupts on a port.
* @ap: Port on which interrupts are enabled.
*
* Note: Original code is ata_sff_irq_on().
*/

static unsigned char bfin_irq_on(struct ata_port *ap)
{
void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
u8 tmp;

dev_dbg(ap->dev, "in atapi irq on\n");
ap->ctl &= ~ATA_NIEN;
ap->last_ctl = ap->ctl;

write_atapi_register(base, ATA_REG_CTRL, ap->ctl);
tmp = ata_wait_idle(ap);

bfin_irq_clear(ap);

return tmp;
}

/**
* bfin_thaw - Thaw DMA controller port
* @ap: port to thaw
Expand All @@ -1262,7 +1238,7 @@ void bfin_thaw(struct ata_port *ap)
{
dev_dbg(ap->dev, "in atapi dma thaw\n");
bfin_check_status(ap);
bfin_irq_on(ap);
ata_sff_irq_on(ap);
}

/**
Expand All @@ -1279,7 +1255,7 @@ static void bfin_postreset(struct ata_link *link, unsigned int *classes)
void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;

/* re-enable interrupts */
bfin_irq_on(ap);
ata_sff_irq_on(ap);

/* is double-select really necessary? */
if (classes[0] != ATA_DEV_NONE)
Expand Down Expand Up @@ -1477,7 +1453,6 @@ static struct ata_port_operations bfin_pata_ops = {
.postreset = bfin_postreset,

.sff_irq_clear = bfin_irq_clear,
.sff_irq_on = bfin_irq_on,

.port_start = bfin_port_start,
.port_stop = bfin_port_stop,
Expand Down
3 changes: 1 addition & 2 deletions drivers/ata/pata_octeon_cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,8 @@ static void octeon_cf_exec_command16(struct ata_port *ap,
ata_wait_idle(ap);
}

static u8 octeon_cf_irq_on(struct ata_port *ap)
static void octeon_cf_irq_on(struct ata_port *ap)
{
return 0;
}

static void octeon_cf_irq_clear(struct ata_port *ap)
Expand Down
24 changes: 0 additions & 24 deletions drivers/ata/pata_scc.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,29 +827,6 @@ static unsigned int scc_data_xfer (struct ata_device *dev, unsigned char *buf,
return words << 1;
}

/**
* scc_irq_on - Enable interrupts on a port.
* @ap: Port on which interrupts are enabled.
*
* Note: Original code is ata_sff_irq_on().
*/

static u8 scc_irq_on (struct ata_port *ap)
{
struct ata_ioports *ioaddr = &ap->ioaddr;
u8 tmp;

ap->ctl &= ~ATA_NIEN;
ap->last_ctl = ap->ctl;

out_be32(ioaddr->ctl_addr, ap->ctl);
tmp = ata_wait_idle(ap);

ap->ops->sff_irq_clear(ap);

return tmp;
}

/**
* scc_pata_prereset - prepare for reset
* @ap: ATA port to be reset
Expand Down Expand Up @@ -977,7 +954,6 @@ static struct ata_port_operations scc_pata_ops = {
.post_internal_cmd = scc_bmdma_stop,

.sff_irq_clear = scc_irq_clear,
.sff_irq_on = scc_irq_on,

.port_start = scc_port_start,
.port_stop = scc_port_stop,
Expand Down
4 changes: 2 additions & 2 deletions include/linux/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ struct ata_port_operations {
const struct ata_taskfile *tf);
unsigned int (*sff_data_xfer)(struct ata_device *dev,
unsigned char *buf, unsigned int buflen, int rw);
u8 (*sff_irq_on)(struct ata_port *);
void (*sff_irq_on)(struct ata_port *);
bool (*sff_irq_check)(struct ata_port *);
void (*sff_irq_clear)(struct ata_port *);

Expand Down Expand Up @@ -1599,7 +1599,7 @@ extern unsigned int ata_sff_data_xfer32(struct ata_device *dev,
unsigned char *buf, unsigned int buflen, int rw);
extern unsigned int ata_sff_data_xfer_noirq(struct ata_device *dev,
unsigned char *buf, unsigned int buflen, int rw);
extern u8 ata_sff_irq_on(struct ata_port *ap);
extern void ata_sff_irq_on(struct ata_port *ap);
extern void ata_sff_irq_clear(struct ata_port *ap);
extern int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
u8 status, int in_wq);
Expand Down

0 comments on commit e42a542

Please sign in to comment.