aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide.c139
1 files changed, 1 insertions, 138 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index f65be738b16a..6f600d81a972 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -722,89 +722,13 @@ set_val:
722EXPORT_SYMBOL(generic_ide_ioctl); 722EXPORT_SYMBOL(generic_ide_ioctl);
723 723
724/* 724/*
725 * stridx() returns the offset of c within s,
726 * or -1 if c is '\0' or not found within s.
727 */
728static int __init stridx (const char *s, char c)
729{
730 char *i = strchr(s, c);
731 return (i && c) ? i - s : -1;
732}
733
734/*
735 * match_parm() does parsing for ide_setup():
736 *
737 * 1. the first char of s must be '='.
738 * 2. if the remainder matches one of the supplied keywords,
739 * the index (1 based) of the keyword is negated and returned.
740 * 3. if the remainder is a series of no more than max_vals numbers
741 * separated by commas, the numbers are saved in vals[] and a
742 * count of how many were saved is returned. Base10 is assumed,
743 * and base16 is allowed when prefixed with "0x".
744 * 4. otherwise, zero is returned.
745 */
746static int __init match_parm (char *s, const char *keywords[], int vals[], int max_vals)
747{
748 static const char *decimal = "0123456789";
749 static const char *hex = "0123456789abcdef";
750 int i, n;
751
752 if (*s++ == '=') {
753 /*
754 * Try matching against the supplied keywords,
755 * and return -(index+1) if we match one
756 */
757 if (keywords != NULL) {
758 for (i = 0; *keywords != NULL; ++i) {
759 if (!strcmp(s, *keywords++))
760 return -(i+1);
761 }
762 }
763 /*
764 * Look for a series of no more than "max_vals"
765 * numeric values separated by commas, in base10,
766 * or base16 when prefixed with "0x".
767 * Return a count of how many were found.
768 */
769 for (n = 0; (i = stridx(decimal, *s)) >= 0;) {
770 vals[n] = i;
771 while ((i = stridx(decimal, *++s)) >= 0)
772 vals[n] = (vals[n] * 10) + i;
773 if (*s == 'x' && !vals[n]) {
774 while ((i = stridx(hex, *++s)) >= 0)
775 vals[n] = (vals[n] * 0x10) + i;
776 }
777 if (++n == max_vals)
778 break;
779 if (*s == ',' || *s == ';')
780 ++s;
781 }
782 if (!*s)
783 return n;
784 }
785 return 0; /* zero = nothing matched */
786}
787
788/*
789 * ide_setup() gets called VERY EARLY during initialization, 725 * ide_setup() gets called VERY EARLY during initialization,
790 * to handle kernel "command line" strings beginning with "hdx=" or "ide". 726 * to handle kernel "command line" strings beginning with "ide".
791 * 727 *
792 * Remember to update Documentation/ide/ide.txt if you change something here. 728 * Remember to update Documentation/ide/ide.txt if you change something here.
793 */ 729 */
794static int __init ide_setup(char *s) 730static int __init ide_setup(char *s)
795{ 731{
796 ide_hwif_t *hwif;
797 ide_drive_t *drive;
798 unsigned int hw, unit;
799 int vals[3];
800 const char max_drive = 'a' + ((MAX_HWIFS * MAX_DRIVES) - 1);
801
802 if (strncmp(s,"hd",2) == 0 && s[2] == '=') /* hd= is for hd.c */
803 return 0; /* driver and not us */
804
805 if (strncmp(s, "ide", 3) && strncmp(s, "hd", 2))
806 return 0;
807
808 printk(KERN_INFO "ide_setup: %s", s); 732 printk(KERN_INFO "ide_setup: %s", s);
809 init_ide_data (); 733 init_ide_data ();
810 734
@@ -842,67 +766,6 @@ static int __init ide_setup(char *s)
842 } 766 }
843#endif /* CONFIG_BLK_DEV_IDEACPI */ 767#endif /* CONFIG_BLK_DEV_IDEACPI */
844 768
845 /*
846 * Look for drive options: "hdx="
847 */
848 if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) {
849 const char *hd_words[] = {
850 "none", "noprobe", "nowerr", "cdrom", "nodma",
851 "-6", "-7", "-8", "-9", "-10",
852 "noflush", "remap", "remap63", "scsi", NULL };
853 unit = s[2] - 'a';
854 hw = unit / MAX_DRIVES;
855 unit = unit % MAX_DRIVES;
856 hwif = &ide_hwifs[hw];
857 drive = &hwif->drives[unit];
858 if (strncmp(s + 4, "ide-", 4) == 0) {
859 strlcpy(drive->driver_req, s + 4, sizeof(drive->driver_req));
860 goto obsolete_option;
861 }
862 switch (match_parm(&s[3], hd_words, vals, 3)) {
863 case -1: /* "none" */
864 case -2: /* "noprobe" */
865 drive->noprobe = 1;
866 goto obsolete_option;
867 case -3: /* "nowerr" */
868 drive->bad_wstat = BAD_R_STAT;
869 goto obsolete_option;
870 case -4: /* "cdrom" */
871 drive->present = 1;
872 drive->media = ide_cdrom;
873 /* an ATAPI device ignores DRDY */
874 drive->ready_stat = 0;
875 goto obsolete_option;
876 case -5: /* nodma */
877 drive->nodma = 1;
878 goto obsolete_option;
879 case -11: /* noflush */
880 drive->noflush = 1;
881 goto obsolete_option;
882 case -12: /* "remap" */
883 drive->remap_0_to_1 = 1;
884 goto obsolete_option;
885 case -13: /* "remap63" */
886 drive->sect0 = 63;
887 goto obsolete_option;
888 case -14: /* "scsi" */
889 drive->scsi = 1;
890 goto obsolete_option;
891 case 3: /* cyl,head,sect */
892 drive->media = ide_disk;
893 drive->ready_stat = READY_STAT;
894 drive->cyl = drive->bios_cyl = vals[0];
895 drive->head = drive->bios_head = vals[1];
896 drive->sect = drive->bios_sect = vals[2];
897 drive->present = 1;
898 drive->forced_geom = 1;
899 goto obsolete_option;
900 default:
901 goto bad_option;
902 }
903 }
904
905bad_option:
906 printk(" -- BAD OPTION\n"); 769 printk(" -- BAD OPTION\n");
907 return 1; 770 return 1;
908obsolete_option: 771obsolete_option: