aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-07 00:14:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-07 00:14:42 -0400
commit33caee39925b887a99a2400dc5c980097c3573f9 (patch)
tree8e68ad97e1fee88c4a3f31453041f8d139f2027e /drivers/ata
parent6456a0438b984186a0c9c8ecc9fe3d97b7ac3613 (diff)
parentf84223087402c45179be5e7060c5736c17a7b271 (diff)
Merge branch 'akpm' (patchbomb from Andrew Morton)
Merge incoming from Andrew Morton: - Various misc things. - arch/sh updates. - Part of ocfs2. Review is slow. - Slab updates. - Most of -mm. - printk updates. - lib/ updates. - checkpatch updates. * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (226 commits) checkpatch: update $declaration_macros, add uninitialized_var checkpatch: warn on missing spaces in broken up quoted checkpatch: fix false positives for --strict "space after cast" test checkpatch: fix false positive MISSING_BREAK warnings with --file checkpatch: add test for native c90 types in unusual order checkpatch: add signed generic types checkpatch: add short int to c variable types checkpatch: add for_each tests to indentation and brace tests checkpatch: fix brace style misuses of else and while checkpatch: add --fix option for a couple OPEN_BRACE misuses checkpatch: use the correct indentation for which() checkpatch: add fix_insert_line and fix_delete_line helpers checkpatch: add ability to insert and delete lines to patch/file checkpatch: add an index variable for fixed lines checkpatch: warn on break after goto or return with same tab indentation checkpatch: emit a warning on file add/move/delete checkpatch: add test for commit id formatting style in commit log checkpatch: emit fewer kmalloc_array/kcalloc conversion warnings checkpatch: improve "no space after cast" test checkpatch: allow multiple const * types ...
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/Kconfig1
-rw-r--r--drivers/ata/libata-core.c72
2 files changed, 4 insertions, 69 deletions
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index e65d400efd44..e1b92788c225 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -16,6 +16,7 @@ menuconfig ATA
16 depends on BLOCK 16 depends on BLOCK
17 depends on !(M32R || M68K || S390) || BROKEN 17 depends on !(M32R || M68K || S390) || BROKEN
18 select SCSI 18 select SCSI
19 select GLOB
19 ---help--- 20 ---help---
20 If you want to use an ATA hard disk, ATA tape drive, ATA CD-ROM or 21 If you want to use an ATA hard disk, ATA tape drive, ATA CD-ROM or
21 any other ATA device under Linux, say Y and make sure that you know 22 any other ATA device under Linux, say Y and make sure that you know
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 677c0c1b03bd..dbdc5d32343f 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -59,6 +59,7 @@
59#include <linux/async.h> 59#include <linux/async.h>
60#include <linux/log2.h> 60#include <linux/log2.h>
61#include <linux/slab.h> 61#include <linux/slab.h>
62#include <linux/glob.h>
62#include <scsi/scsi.h> 63#include <scsi/scsi.h>
63#include <scsi/scsi_cmnd.h> 64#include <scsi/scsi_cmnd.h>
64#include <scsi/scsi_host.h> 65#include <scsi/scsi_host.h>
@@ -4250,73 +4251,6 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4250 { } 4251 { }
4251}; 4252};
4252 4253
4253/**
4254 * glob_match - match a text string against a glob-style pattern
4255 * @text: the string to be examined
4256 * @pattern: the glob-style pattern to be matched against
4257 *
4258 * Either/both of text and pattern can be empty strings.
4259 *
4260 * Match text against a glob-style pattern, with wildcards and simple sets:
4261 *
4262 * ? matches any single character.
4263 * * matches any run of characters.
4264 * [xyz] matches a single character from the set: x, y, or z.
4265 * [a-d] matches a single character from the range: a, b, c, or d.
4266 * [a-d0-9] matches a single character from either range.
4267 *
4268 * The special characters ?, [, -, or *, can be matched using a set, eg. [*]
4269 * Behaviour with malformed patterns is undefined, though generally reasonable.
4270 *
4271 * Sample patterns: "SD1?", "SD1[0-5]", "*R0", "SD*1?[012]*xx"
4272 *
4273 * This function uses one level of recursion per '*' in pattern.
4274 * Since it calls _nothing_ else, and has _no_ explicit local variables,
4275 * this will not cause stack problems for any reasonable use here.
4276 *
4277 * RETURNS:
4278 * 0 on match, 1 otherwise.
4279 */
4280static int glob_match (const char *text, const char *pattern)
4281{
4282 do {
4283 /* Match single character or a '?' wildcard */
4284 if (*text == *pattern || *pattern == '?') {
4285 if (!*pattern++)
4286 return 0; /* End of both strings: match */
4287 } else {
4288 /* Match single char against a '[' bracketed ']' pattern set */
4289 if (!*text || *pattern != '[')
4290 break; /* Not a pattern set */
4291 while (*++pattern && *pattern != ']' && *text != *pattern) {
4292 if (*pattern == '-' && *(pattern - 1) != '[')
4293 if (*text > *(pattern - 1) && *text < *(pattern + 1)) {
4294 ++pattern;
4295 break;
4296 }
4297 }
4298 if (!*pattern || *pattern == ']')
4299 return 1; /* No match */
4300 while (*pattern && *pattern++ != ']');
4301 }
4302 } while (*++text && *pattern);
4303
4304 /* Match any run of chars against a '*' wildcard */
4305 if (*pattern == '*') {
4306 if (!*++pattern)
4307 return 0; /* Match: avoid recursion at end of pattern */
4308 /* Loop to handle additional pattern chars after the wildcard */
4309 while (*text) {
4310 if (glob_match(text, pattern) == 0)
4311 return 0; /* Remainder matched */
4312 ++text; /* Absorb (match) this char and try again */
4313 }
4314 }
4315 if (!*text && !*pattern)
4316 return 0; /* End of both strings: match */
4317 return 1; /* No match */
4318}
4319
4320static unsigned long ata_dev_blacklisted(const struct ata_device *dev) 4254static unsigned long ata_dev_blacklisted(const struct ata_device *dev)
4321{ 4255{
4322 unsigned char model_num[ATA_ID_PROD_LEN + 1]; 4256 unsigned char model_num[ATA_ID_PROD_LEN + 1];
@@ -4327,10 +4261,10 @@ static unsigned long ata_dev_blacklisted(const struct ata_device *dev)
4327 ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev)); 4261 ata_id_c_string(dev->id, model_rev, ATA_ID_FW_REV, sizeof(model_rev));
4328 4262
4329 while (ad->model_num) { 4263 while (ad->model_num) {
4330 if (!glob_match(model_num, ad->model_num)) { 4264 if (glob_match(model_num, ad->model_num)) {
4331 if (ad->model_rev == NULL) 4265 if (ad->model_rev == NULL)
4332 return ad->horkage; 4266 return ad->horkage;
4333 if (!glob_match(model_rev, ad->model_rev)) 4267 if (glob_match(model_rev, ad->model_rev))
4334 return ad->horkage; 4268 return ad->horkage;
4335 } 4269 }
4336 ad++; 4270 ad++;