aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/libata-core.c33
-rw-r--r--include/linux/libata.h10
2 files changed, 29 insertions, 14 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 124b6f111cc3..a2f2ff864b37 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -454,9 +454,8 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
454 * RETURNS: 454 * RETURNS:
455 * Packed xfer_mask. 455 * Packed xfer_mask.
456 */ 456 */
457static unsigned int ata_pack_xfermask(unsigned int pio_mask, 457unsigned int ata_pack_xfermask(unsigned int pio_mask,
458 unsigned int mwdma_mask, 458 unsigned int mwdma_mask, unsigned int udma_mask)
459 unsigned int udma_mask)
460{ 459{
461 return ((pio_mask << ATA_SHIFT_PIO) & ATA_MASK_PIO) | 460 return ((pio_mask << ATA_SHIFT_PIO) & ATA_MASK_PIO) |
462 ((mwdma_mask << ATA_SHIFT_MWDMA) & ATA_MASK_MWDMA) | 461 ((mwdma_mask << ATA_SHIFT_MWDMA) & ATA_MASK_MWDMA) |
@@ -473,10 +472,8 @@ static unsigned int ata_pack_xfermask(unsigned int pio_mask,
473 * Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask. 472 * Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask.
474 * Any NULL distination masks will be ignored. 473 * Any NULL distination masks will be ignored.
475 */ 474 */
476static void ata_unpack_xfermask(unsigned int xfer_mask, 475void ata_unpack_xfermask(unsigned int xfer_mask, unsigned int *pio_mask,
477 unsigned int *pio_mask, 476 unsigned int *mwdma_mask, unsigned int *udma_mask)
478 unsigned int *mwdma_mask,
479 unsigned int *udma_mask)
480{ 477{
481 if (pio_mask) 478 if (pio_mask)
482 *pio_mask = (xfer_mask & ATA_MASK_PIO) >> ATA_SHIFT_PIO; 479 *pio_mask = (xfer_mask & ATA_MASK_PIO) >> ATA_SHIFT_PIO;
@@ -509,7 +506,7 @@ static const struct ata_xfer_ent {
509 * RETURNS: 506 * RETURNS:
510 * Matching XFER_* value, 0 if no match found. 507 * Matching XFER_* value, 0 if no match found.
511 */ 508 */
512static u8 ata_xfer_mask2mode(unsigned int xfer_mask) 509u8 ata_xfer_mask2mode(unsigned int xfer_mask)
513{ 510{
514 int highbit = fls(xfer_mask) - 1; 511 int highbit = fls(xfer_mask) - 1;
515 const struct ata_xfer_ent *ent; 512 const struct ata_xfer_ent *ent;
@@ -532,7 +529,7 @@ static u8 ata_xfer_mask2mode(unsigned int xfer_mask)
532 * RETURNS: 529 * RETURNS:
533 * Matching xfer_mask, 0 if no match found. 530 * Matching xfer_mask, 0 if no match found.
534 */ 531 */
535static unsigned int ata_xfer_mode2mask(u8 xfer_mode) 532unsigned int ata_xfer_mode2mask(u8 xfer_mode)
536{ 533{
537 const struct ata_xfer_ent *ent; 534 const struct ata_xfer_ent *ent;
538 535
@@ -554,7 +551,7 @@ static unsigned int ata_xfer_mode2mask(u8 xfer_mode)
554 * RETURNS: 551 * RETURNS:
555 * Matching xfer_shift, -1 if no match found. 552 * Matching xfer_shift, -1 if no match found.
556 */ 553 */
557static int ata_xfer_mode2shift(unsigned int xfer_mode) 554int ata_xfer_mode2shift(unsigned int xfer_mode)
558{ 555{
559 const struct ata_xfer_ent *ent; 556 const struct ata_xfer_ent *ent;
560 557
@@ -578,7 +575,7 @@ static int ata_xfer_mode2shift(unsigned int xfer_mode)
578 * Constant C string representing highest speed listed in 575 * Constant C string representing highest speed listed in
579 * @mode_mask, or the constant C string "<n/a>". 576 * @mode_mask, or the constant C string "<n/a>".
580 */ 577 */
581static const char *ata_mode_string(unsigned int xfer_mask) 578const char *ata_mode_string(unsigned int xfer_mask)
582{ 579{
583 static const char * const xfer_mode_str[] = { 580 static const char * const xfer_mode_str[] = {
584 "PIO0", 581 "PIO0",
@@ -1468,7 +1465,7 @@ static inline void ata_dump_id(const u16 *id)
1468 * RETURNS: 1465 * RETURNS:
1469 * Computed xfermask 1466 * Computed xfermask
1470 */ 1467 */
1471static unsigned int ata_id_xfermask(const u16 *id) 1468unsigned int ata_id_xfermask(const u16 *id)
1472{ 1469{
1473 unsigned int pio_mask, mwdma_mask, udma_mask; 1470 unsigned int pio_mask, mwdma_mask, udma_mask;
1474 1471
@@ -2855,11 +2852,11 @@ void ata_timing_merge(const struct ata_timing *a, const struct ata_timing *b,
2855 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma); 2852 if (what & ATA_TIMING_UDMA ) m->udma = max(a->udma, b->udma);
2856} 2853}
2857 2854
2858static const struct ata_timing *ata_timing_find_mode(unsigned short speed) 2855const struct ata_timing *ata_timing_find_mode(u8 xfer_mode)
2859{ 2856{
2860 const struct ata_timing *t; 2857 const struct ata_timing *t;
2861 2858
2862 for (t = ata_timing; t->mode != speed; t++) 2859 for (t = ata_timing; t->mode != xfer_mode; t++)
2863 if (t->mode == 0xFF) 2860 if (t->mode == 0xFF)
2864 return NULL; 2861 return NULL;
2865 return t; 2862 return t;
@@ -7590,6 +7587,13 @@ EXPORT_SYMBOL_GPL(ata_std_dev_select);
7590EXPORT_SYMBOL_GPL(sata_print_link_status); 7587EXPORT_SYMBOL_GPL(sata_print_link_status);
7591EXPORT_SYMBOL_GPL(ata_tf_to_fis); 7588EXPORT_SYMBOL_GPL(ata_tf_to_fis);
7592EXPORT_SYMBOL_GPL(ata_tf_from_fis); 7589EXPORT_SYMBOL_GPL(ata_tf_from_fis);
7590EXPORT_SYMBOL_GPL(ata_pack_xfermask);
7591EXPORT_SYMBOL_GPL(ata_unpack_xfermask);
7592EXPORT_SYMBOL_GPL(ata_xfer_mask2mode);
7593EXPORT_SYMBOL_GPL(ata_xfer_mode2mask);
7594EXPORT_SYMBOL_GPL(ata_xfer_mode2shift);
7595EXPORT_SYMBOL_GPL(ata_mode_string);
7596EXPORT_SYMBOL_GPL(ata_id_xfermask);
7593EXPORT_SYMBOL_GPL(ata_check_status); 7597EXPORT_SYMBOL_GPL(ata_check_status);
7594EXPORT_SYMBOL_GPL(ata_altstatus); 7598EXPORT_SYMBOL_GPL(ata_altstatus);
7595EXPORT_SYMBOL_GPL(ata_exec_command); 7599EXPORT_SYMBOL_GPL(ata_exec_command);
@@ -7655,6 +7659,7 @@ EXPORT_SYMBOL_GPL(ata_id_to_dma_mode);
7655EXPORT_SYMBOL_GPL(ata_scsi_simulate); 7659EXPORT_SYMBOL_GPL(ata_scsi_simulate);
7656 7660
7657EXPORT_SYMBOL_GPL(ata_pio_need_iordy); 7661EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
7662EXPORT_SYMBOL_GPL(ata_timing_find_mode);
7658EXPORT_SYMBOL_GPL(ata_timing_compute); 7663EXPORT_SYMBOL_GPL(ata_timing_compute);
7659EXPORT_SYMBOL_GPL(ata_timing_merge); 7664EXPORT_SYMBOL_GPL(ata_timing_merge);
7660 7665
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 131fb6625e14..083dd77b120d 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -851,6 +851,15 @@ extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
851extern void ata_tf_to_fis(const struct ata_taskfile *tf, 851extern void ata_tf_to_fis(const struct ata_taskfile *tf,
852 u8 pmp, int is_cmd, u8 *fis); 852 u8 pmp, int is_cmd, u8 *fis);
853extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); 853extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
854extern unsigned int ata_pack_xfermask(unsigned int pio_mask,
855 unsigned int mwdma_mask, unsigned int udma_mask);
856extern void ata_unpack_xfermask(unsigned int xfer_mask, unsigned int *pio_mask,
857 unsigned int *mwdma_mask, unsigned int *udma_mask);
858extern u8 ata_xfer_mask2mode(unsigned int xfer_mask);
859extern unsigned int ata_xfer_mode2mask(u8 xfer_mode);
860extern int ata_xfer_mode2shift(unsigned int xfer_mode);
861extern const char *ata_mode_string(unsigned int xfer_mask);
862extern unsigned int ata_id_xfermask(const u16 *id);
854extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device); 863extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device);
855extern void ata_std_dev_select(struct ata_port *ap, unsigned int device); 864extern void ata_std_dev_select(struct ata_port *ap, unsigned int device);
856extern u8 ata_check_status(struct ata_port *ap); 865extern u8 ata_check_status(struct ata_port *ap);
@@ -920,6 +929,7 @@ extern int ata_cable_unknown(struct ata_port *ap);
920 */ 929 */
921 930
922extern unsigned int ata_pio_need_iordy(const struct ata_device *); 931extern unsigned int ata_pio_need_iordy(const struct ata_device *);
932extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode);
923extern int ata_timing_compute(struct ata_device *, unsigned short, 933extern int ata_timing_compute(struct ata_device *, unsigned short,
924 struct ata_timing *, int, int); 934 struct ata_timing *, int, int);
925extern void ata_timing_merge(const struct ata_timing *, 935extern void ata_timing_merge(const struct ata_timing *,