* [PATCH] libata-core: support wildcard matching in ata_blacklist_entry @ 2007-08-08 20:20 David Milburn 2007-08-08 23:31 ` Alan Cox 0 siblings, 1 reply; 5+ messages in thread From: David Milburn @ 2007-08-08 20:20 UTC (permalink / raw) To: jeff; +Cc: linux-ide, alan, dmilburn Support the use of '*' in model_num and model_rev entries in ata_device_blacklist[]. CC: alan@lxorguk.ukuu.org.uk Signed-off-by: David Milburn <dmilburn@redhat.com> --- drivers/ata/libata-core.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 60e78be..1c9c208 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3806,10 +3806,17 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev) ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); while (ad->model_num) { - if (!strcmp(ad->model_num, model_num)) { + char *wc; + wc = strchr(ad->model_num, '*'); + if (!strncmp(ad->model_num, model_num, + wc ? wc - ad->model_num : + strlen(ad->model_num))) { if (ad->model_rev == NULL) return ad->horkage; - if (!strcmp(ad->model_rev, model_rev)) + wc = strchr(ad->model_rev, '*'); + if (!strncmp(ad->model_rev, model_rev, + wc ? wc - ad->model_rev : + strlen(ad->model_rev))) return ad->horkage; } ad++; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] libata-core: support wildcard matching in ata_blacklist_entry 2007-08-08 20:20 [PATCH] libata-core: support wildcard matching in ata_blacklist_entry David Milburn @ 2007-08-08 23:31 ` Alan Cox 2007-08-16 19:07 ` Jeff Garzik 0 siblings, 1 reply; 5+ messages in thread From: Alan Cox @ 2007-08-08 23:31 UTC (permalink / raw) Cc: jeff, linux-ide, dmilburn On Wed, 8 Aug 2007 15:20:57 -0500 David Milburn <dmilburn@redhat.com> wrote: > Support the use of '*' in model_num and model_rev entries > in ata_device_blacklist[]. > > CC: alan@lxorguk.ukuu.org.uk > Signed-off-by: David Milburn <dmilburn@redhat.com> Suggestion: Pull the match function out of line so you don't have two copies of it and can remove all the wacky ? operators something like this ? (untested) strpatterncmp(const char *name, const char *patt) { const char *p = strchr(patt, '*'); if (p == NULL) p = patt + strlen(patt); return strncmp(name, patt, p-patt); } ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libata-core: support wildcard matching in ata_blacklist_entry 2007-08-08 23:31 ` Alan Cox @ 2007-08-16 19:07 ` Jeff Garzik 0 siblings, 0 replies; 5+ messages in thread From: Jeff Garzik @ 2007-08-16 19:07 UTC (permalink / raw) To: Alan Cox; +Cc: David Milburn, linux-ide Alan Cox wrote: > On Wed, 8 Aug 2007 15:20:57 -0500 > David Milburn <dmilburn@redhat.com> wrote: > >> Support the use of '*' in model_num and model_rev entries >> in ata_device_blacklist[]. >> >> CC: alan@lxorguk.ukuu.org.uk >> Signed-off-by: David Milburn <dmilburn@redhat.com> > > Suggestion: Pull the match function out of line so you don't have two > copies of it and can remove all the wacky ? operators > > something like this ? (untested) > > strpatterncmp(const char *name, const char *patt) > { > const char *p = strchr(patt, '*'); > if (p == NULL) > p = patt + strlen(patt); > return strncmp(name, patt, p-patt); > } Seems quite sane to me... And I support the addition of wildcard operators; that should make maintenance a bit easier. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] libata-core: support wildcard matching in ata_blacklist_entry @ 2007-08-09 20:49 David Milburn 2007-09-20 20:33 ` Jeff Garzik 0 siblings, 1 reply; 5+ messages in thread From: David Milburn @ 2007-08-09 20:49 UTC (permalink / raw) To: jeff; +Cc: linux-ide, alan, dmilburn Support the use of '*' in model_num and model_rev entries in ata_device_blacklist[]. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: David Milburn <dmilburn@redhat.com> --- libata-core.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 60e78be..4603bd9 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3796,6 +3796,18 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { } }; +int strn_pattern_cmp(const char *patt, const char *name, int c) +{ + const char *p = strchr(patt, c); + int len; + + if (p == NULL) + len = strlen(name); + else + len = p-patt; + return strncmp(patt, name, len); +} + static unsigned long ata_dev_blacklisted(const struct ata_device *dev) { unsigned char model_num[ATA_ID_PROD_LEN + 1]; @@ -3806,10 +3818,10 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev) ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); while (ad->model_num) { - if (!strcmp(ad->model_num, model_num)) { + if (!strn_pattern_cmp(ad->model_num, model_num, '*')) { if (ad->model_rev == NULL) return ad->horkage; - if (!strcmp(ad->model_rev, model_rev)) + if (!strn_pattern_cmp(ad->model_rev, model_rev, '*')) return ad->horkage; } ad++; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] libata-core: support wildcard matching in ata_blacklist_entry 2007-08-09 20:49 David Milburn @ 2007-09-20 20:33 ` Jeff Garzik 0 siblings, 0 replies; 5+ messages in thread From: Jeff Garzik @ 2007-09-20 20:33 UTC (permalink / raw) To: David Milburn; +Cc: linux-ide, alan [-- Attachment #1: Type: text/plain, Size: 250 bytes --] David Milburn wrote: > Support the use of '*' in model_num and model_rev entries > in ata_device_blacklist[]. > > Signed-off-by: Alan Cox <alan@redhat.com> > Signed-off-by: David Milburn <dmilburn@redhat.com> applied a modified version (attached) [-- Attachment #2: patch --] [-- Type: text/plain, Size: 2857 bytes --] commit 6d7fdd50ff25e6997ab581a2eff0a53f9228829a Author: Jeff Garzik <jeff@garzik.org> Date: Thu Sep 20 16:31:47 2007 -0400 [libata] blacklist Maxtor*BANC* using new wildcard blacklist matching Support the use of '*' in model_num and model_rev entries in ata_device_blacklist[]. Based largely on David Milburn's "libata-core: support wildcard matching in ata_blacklist_entry" patch. Signed-off-by: Jeff Garzik <jeff@garzik.org> drivers/ata/libata-core.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) 6d7fdd50ff25e6997ab581a2eff0a53f9228829a diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 84d81b2..2b22270 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -3814,16 +3814,11 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { /* http://thread.gmane.org/gmane.linux.ide/14907 */ { "FUJITSU MHT2060BH", NULL, ATA_HORKAGE_NONCQ }, /* NCQ is broken */ - { "Maxtor 6L250S0", "BANC1G10", ATA_HORKAGE_NONCQ }, - { "Maxtor 6B200M0", "BANC1BM0", ATA_HORKAGE_NONCQ }, - { "Maxtor 6B200M0", "BANC1B10", ATA_HORKAGE_NONCQ }, - { "Maxtor 7B250S0", "BANC1B70", ATA_HORKAGE_NONCQ, }, - { "Maxtor 7B300S0", "BANC1B70", ATA_HORKAGE_NONCQ }, + { "Maxtor *", "BANC*", ATA_HORKAGE_NONCQ }, { "Maxtor 7V300F0", "VA111630", ATA_HORKAGE_NONCQ }, { "HITACHI HDS7250SASUN500G 0621KTAWSD", "K2AOAJ0AHITACHI", - ATA_HORKAGE_NONCQ }, - /* NCQ hard hangs device under heavier load, needs hard power cycle */ - { "Maxtor 6B250S0", "BANC1B70", ATA_HORKAGE_NONCQ }, + ATA_HORKAGE_NONCQ }, + /* Blacklist entries taken from Silicon Image 3124/3132 Windows driver .inf file - also several Linux problem reports */ { "HTS541060G9SA00", "MB3OC60D", ATA_HORKAGE_NONCQ, }, @@ -3849,6 +3844,23 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { } }; +int strn_pattern_cmp(const char *patt, const char *name, int wildchar) +{ + const char *p; + int len; + + /* + * check for trailing wildcard: *\0 + */ + p = strchr(patt, wildchar); + if (p && ((*(p + 1)) == 0)) + len = p - patt; + else + len = strlen(name); + + return strncmp(patt, name, len); +} + static unsigned long ata_dev_blacklisted(const struct ata_device *dev) { unsigned char model_num[ATA_ID_PROD_LEN + 1]; @@ -3859,10 +3871,10 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev) ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); while (ad->model_num) { - if (!strcmp(ad->model_num, model_num)) { + if (!strn_pattern_cmp(ad->model_num, model_num, '*')) { if (ad->model_rev == NULL) return ad->horkage; - if (!strcmp(ad->model_rev, model_rev)) + if (!strn_pattern_cmp(ad->model_rev, model_rev, '*')) return ad->horkage; } ad++; ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-09-20 20:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-08-08 20:20 [PATCH] libata-core: support wildcard matching in ata_blacklist_entry David Milburn 2007-08-08 23:31 ` Alan Cox 2007-08-16 19:07 ` Jeff Garzik -- strict thread matches above, loose matches on Subject: below -- 2007-08-09 20:49 David Milburn 2007-09-20 20:33 ` Jeff Garzik
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).