diff options
author | Michal Nazarewicz <m.nazarewicz@samsung.com> | 2009-10-28 11:57:15 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 14:55:18 -0500 |
commit | d6181702f510302dce5666a50344b5acb196ab4e (patch) | |
tree | 82b28ab17bcc357cd290d79c0590a4d9b514ff8e /drivers/usb/gadget/storage_common.c | |
parent | b6058d0fefc0b5ff777dfbff990a0a50a4ac144b (diff) |
USB: g_file_storage: "fsg_" prefix added to some identifiers
Prefixed some identifiers that were defined in storage_common.c file
with "fsg_". Not all identifiers were prefixed but the ones that are
most likely to produce conflicts when used with other USB functions.
Signed-off-by: Michal Nazarewicz <m.nazarewicz@samsung.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/storage_common.c')
-rw-r--r-- | drivers/usb/gadget/storage_common.c | 132 |
1 files changed, 79 insertions, 53 deletions
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index fa86fdaafc1d..19bf1e330dd0 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -4,9 +4,38 @@ | |||
4 | * Copyright (C) 2003-2008 Alan Stern | 4 | * Copyright (C) 2003-2008 Alan Stern |
5 | * Copyeight (C) 2009 Samsung Electronics | 5 | * Copyeight (C) 2009 Samsung Electronics |
6 | * Author: Michal Nazarewicz (m.nazarewicz@samsung.com) | 6 | * Author: Michal Nazarewicz (m.nazarewicz@samsung.com) |
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | |||
24 | /* | ||
25 | * This file requires the following identifiers used in USB strings to | ||
26 | * be defined (each of type pointer to char): | ||
27 | * - fsg_string_manufacturer -- name of the manufacturer | ||
28 | * - fsg_string_product -- name of the product | ||
29 | * - fsg_string_serial -- product's serial | ||
30 | * - fsg_string_config -- name of the configuration | ||
31 | * - fsg_string_interface -- name of the interface | ||
32 | * The first four are only needed when FSG_DESCRIPTORS_DEVICE_STRINGS | ||
33 | * macro is defined prior to including this file. | ||
7 | */ | 34 | */ |
8 | 35 | ||
9 | 36 | ||
37 | #include <asm/unaligned.h> | ||
38 | |||
10 | 39 | ||
11 | /*-------------------------------------------------------------------------*/ | 40 | /*-------------------------------------------------------------------------*/ |
12 | 41 | ||
@@ -93,7 +122,7 @@ | |||
93 | /* Bulk-only data structures */ | 122 | /* Bulk-only data structures */ |
94 | 123 | ||
95 | /* Command Block Wrapper */ | 124 | /* Command Block Wrapper */ |
96 | struct bulk_cb_wrap { | 125 | struct fsg_bulk_cb_wrap { |
97 | __le32 Signature; // Contains 'USBC' | 126 | __le32 Signature; // Contains 'USBC' |
98 | u32 Tag; // Unique per command id | 127 | u32 Tag; // Unique per command id |
99 | __le32 DataTransferLength; // Size of the data | 128 | __le32 DataTransferLength; // Size of the data |
@@ -191,7 +220,7 @@ struct interrupt_data { | |||
191 | /*-------------------------------------------------------------------------*/ | 220 | /*-------------------------------------------------------------------------*/ |
192 | 221 | ||
193 | 222 | ||
194 | struct lun { | 223 | struct fsg_lun { |
195 | struct file *filp; | 224 | struct file *filp; |
196 | loff_t file_length; | 225 | loff_t file_length; |
197 | loff_t num_sectors; | 226 | loff_t num_sectors; |
@@ -208,11 +237,11 @@ struct lun { | |||
208 | struct device dev; | 237 | struct device dev; |
209 | }; | 238 | }; |
210 | 239 | ||
211 | #define backing_file_is_open(curlun) ((curlun)->filp != NULL) | 240 | #define fsg_lun_is_open(curlun) ((curlun)->filp != NULL) |
212 | 241 | ||
213 | static struct lun *dev_to_lun(struct device *dev) | 242 | static struct fsg_lun *fsg_lun_from_dev(struct device *dev) |
214 | { | 243 | { |
215 | return container_of(dev, struct lun, dev); | 244 | return container_of(dev, struct fsg_lun, dev); |
216 | } | 245 | } |
217 | 246 | ||
218 | 247 | ||
@@ -221,7 +250,7 @@ static struct lun *dev_to_lun(struct device *dev) | |||
221 | #define DELAYED_STATUS (EP0_BUFSIZE + 999) // An impossibly large value | 250 | #define DELAYED_STATUS (EP0_BUFSIZE + 999) // An impossibly large value |
222 | 251 | ||
223 | /* Number of buffers we will use. 2 is enough for double-buffering */ | 252 | /* Number of buffers we will use. 2 is enough for double-buffering */ |
224 | #define NUM_BUFFERS 2 | 253 | #define FSG_NUM_BUFFERS 2 |
225 | 254 | ||
226 | enum fsg_buffer_state { | 255 | enum fsg_buffer_state { |
227 | BUF_STATE_EMPTY = 0, | 256 | BUF_STATE_EMPTY = 0, |
@@ -280,16 +309,18 @@ static inline u32 get_unaligned_be24(u8 *buf) | |||
280 | /*-------------------------------------------------------------------------*/ | 309 | /*-------------------------------------------------------------------------*/ |
281 | 310 | ||
282 | 311 | ||
283 | #define STRING_MANUFACTURER 1 | 312 | enum { |
284 | #define STRING_PRODUCT 2 | 313 | FSG_STRING_MANUFACTURER = 1, |
285 | #define STRING_SERIAL 3 | 314 | FSG_STRING_PRODUCT, |
286 | #define STRING_CONFIG 4 | 315 | FSG_STRING_SERIAL, |
287 | #define STRING_INTERFACE 5 | 316 | FSG_STRING_CONFIG, |
317 | FSG_STRING_INTERFACE | ||
318 | }; | ||
288 | 319 | ||
289 | 320 | ||
290 | static struct usb_otg_descriptor | 321 | static struct usb_otg_descriptor |
291 | otg_desc = { | 322 | fsg_otg_desc = { |
292 | .bLength = sizeof(otg_desc), | 323 | .bLength = sizeof fsg_otg_desc, |
293 | .bDescriptorType = USB_DT_OTG, | 324 | .bDescriptorType = USB_DT_OTG, |
294 | 325 | ||
295 | .bmAttributes = USB_OTG_SRP, | 326 | .bmAttributes = USB_OTG_SRP, |
@@ -298,22 +329,22 @@ otg_desc = { | |||
298 | /* There is only one interface. */ | 329 | /* There is only one interface. */ |
299 | 330 | ||
300 | static struct usb_interface_descriptor | 331 | static struct usb_interface_descriptor |
301 | intf_desc = { | 332 | fsg_intf_desc = { |
302 | .bLength = sizeof intf_desc, | 333 | .bLength = sizeof fsg_intf_desc, |
303 | .bDescriptorType = USB_DT_INTERFACE, | 334 | .bDescriptorType = USB_DT_INTERFACE, |
304 | 335 | ||
305 | .bNumEndpoints = 2, // Adjusted during fsg_bind() | 336 | .bNumEndpoints = 2, // Adjusted during fsg_bind() |
306 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, | 337 | .bInterfaceClass = USB_CLASS_MASS_STORAGE, |
307 | .bInterfaceSubClass = USB_SC_SCSI, // Adjusted during fsg_bind() | 338 | .bInterfaceSubClass = USB_SC_SCSI, // Adjusted during fsg_bind() |
308 | .bInterfaceProtocol = USB_PR_BULK, // Adjusted during fsg_bind() | 339 | .bInterfaceProtocol = USB_PR_BULK, // Adjusted during fsg_bind() |
309 | .iInterface = STRING_INTERFACE, | 340 | .iInterface = FSG_STRING_INTERFACE, |
310 | }; | 341 | }; |
311 | 342 | ||
312 | /* Three full-speed endpoint descriptors: bulk-in, bulk-out, | 343 | /* Three full-speed endpoint descriptors: bulk-in, bulk-out, |
313 | * and interrupt-in. */ | 344 | * and interrupt-in. */ |
314 | 345 | ||
315 | static struct usb_endpoint_descriptor | 346 | static struct usb_endpoint_descriptor |
316 | fs_bulk_in_desc = { | 347 | fsg_fs_bulk_in_desc = { |
317 | .bLength = USB_DT_ENDPOINT_SIZE, | 348 | .bLength = USB_DT_ENDPOINT_SIZE, |
318 | .bDescriptorType = USB_DT_ENDPOINT, | 349 | .bDescriptorType = USB_DT_ENDPOINT, |
319 | 350 | ||
@@ -323,7 +354,7 @@ fs_bulk_in_desc = { | |||
323 | }; | 354 | }; |
324 | 355 | ||
325 | static struct usb_endpoint_descriptor | 356 | static struct usb_endpoint_descriptor |
326 | fs_bulk_out_desc = { | 357 | fsg_fs_bulk_out_desc = { |
327 | .bLength = USB_DT_ENDPOINT_SIZE, | 358 | .bLength = USB_DT_ENDPOINT_SIZE, |
328 | .bDescriptorType = USB_DT_ENDPOINT, | 359 | .bDescriptorType = USB_DT_ENDPOINT, |
329 | 360 | ||
@@ -333,7 +364,7 @@ fs_bulk_out_desc = { | |||
333 | }; | 364 | }; |
334 | 365 | ||
335 | static struct usb_endpoint_descriptor | 366 | static struct usb_endpoint_descriptor |
336 | fs_intr_in_desc = { | 367 | fsg_fs_intr_in_desc = { |
337 | .bLength = USB_DT_ENDPOINT_SIZE, | 368 | .bLength = USB_DT_ENDPOINT_SIZE, |
338 | .bDescriptorType = USB_DT_ENDPOINT, | 369 | .bDescriptorType = USB_DT_ENDPOINT, |
339 | 370 | ||
@@ -343,15 +374,15 @@ fs_intr_in_desc = { | |||
343 | .bInterval = 32, // frames -> 32 ms | 374 | .bInterval = 32, // frames -> 32 ms |
344 | }; | 375 | }; |
345 | 376 | ||
346 | static const struct usb_descriptor_header *fs_function[] = { | 377 | static const struct usb_descriptor_header *fsg_fs_function[] = { |
347 | (struct usb_descriptor_header *) &otg_desc, | 378 | (struct usb_descriptor_header *) &fsg_otg_desc, |
348 | (struct usb_descriptor_header *) &intf_desc, | 379 | (struct usb_descriptor_header *) &fsg_intf_desc, |
349 | (struct usb_descriptor_header *) &fs_bulk_in_desc, | 380 | (struct usb_descriptor_header *) &fsg_fs_bulk_in_desc, |
350 | (struct usb_descriptor_header *) &fs_bulk_out_desc, | 381 | (struct usb_descriptor_header *) &fsg_fs_bulk_out_desc, |
351 | (struct usb_descriptor_header *) &fs_intr_in_desc, | 382 | (struct usb_descriptor_header *) &fsg_fs_intr_in_desc, |
352 | NULL, | 383 | NULL, |
353 | }; | 384 | }; |
354 | #define FS_FUNCTION_PRE_EP_ENTRIES 2 | 385 | #define FSG_FS_FUNCTION_PRE_EP_ENTRIES 2 |
355 | 386 | ||
356 | 387 | ||
357 | /* | 388 | /* |
@@ -363,7 +394,7 @@ static const struct usb_descriptor_header *fs_function[] = { | |||
363 | * for the config descriptor. | 394 | * for the config descriptor. |
364 | */ | 395 | */ |
365 | static struct usb_endpoint_descriptor | 396 | static struct usb_endpoint_descriptor |
366 | hs_bulk_in_desc = { | 397 | fsg_hs_bulk_in_desc = { |
367 | .bLength = USB_DT_ENDPOINT_SIZE, | 398 | .bLength = USB_DT_ENDPOINT_SIZE, |
368 | .bDescriptorType = USB_DT_ENDPOINT, | 399 | .bDescriptorType = USB_DT_ENDPOINT, |
369 | 400 | ||
@@ -373,7 +404,7 @@ hs_bulk_in_desc = { | |||
373 | }; | 404 | }; |
374 | 405 | ||
375 | static struct usb_endpoint_descriptor | 406 | static struct usb_endpoint_descriptor |
376 | hs_bulk_out_desc = { | 407 | fsg_hs_bulk_out_desc = { |
377 | .bLength = USB_DT_ENDPOINT_SIZE, | 408 | .bLength = USB_DT_ENDPOINT_SIZE, |
378 | .bDescriptorType = USB_DT_ENDPOINT, | 409 | .bDescriptorType = USB_DT_ENDPOINT, |
379 | 410 | ||
@@ -384,7 +415,7 @@ hs_bulk_out_desc = { | |||
384 | }; | 415 | }; |
385 | 416 | ||
386 | static struct usb_endpoint_descriptor | 417 | static struct usb_endpoint_descriptor |
387 | hs_intr_in_desc = { | 418 | fsg_hs_intr_in_desc = { |
388 | .bLength = USB_DT_ENDPOINT_SIZE, | 419 | .bLength = USB_DT_ENDPOINT_SIZE, |
389 | .bDescriptorType = USB_DT_ENDPOINT, | 420 | .bDescriptorType = USB_DT_ENDPOINT, |
390 | 421 | ||
@@ -394,19 +425,19 @@ hs_intr_in_desc = { | |||
394 | .bInterval = 9, // 2**(9-1) = 256 uframes -> 32 ms | 425 | .bInterval = 9, // 2**(9-1) = 256 uframes -> 32 ms |
395 | }; | 426 | }; |
396 | 427 | ||
397 | static const struct usb_descriptor_header *hs_function[] = { | 428 | static const struct usb_descriptor_header *fsg_hs_function[] = { |
398 | (struct usb_descriptor_header *) &otg_desc, | 429 | (struct usb_descriptor_header *) &fsg_otg_desc, |
399 | (struct usb_descriptor_header *) &intf_desc, | 430 | (struct usb_descriptor_header *) &fsg_intf_desc, |
400 | (struct usb_descriptor_header *) &hs_bulk_in_desc, | 431 | (struct usb_descriptor_header *) &fsg_hs_bulk_in_desc, |
401 | (struct usb_descriptor_header *) &hs_bulk_out_desc, | 432 | (struct usb_descriptor_header *) &fsg_hs_bulk_out_desc, |
402 | (struct usb_descriptor_header *) &hs_intr_in_desc, | 433 | (struct usb_descriptor_header *) &fsg_hs_intr_in_desc, |
403 | NULL, | 434 | NULL, |
404 | }; | 435 | }; |
405 | #define HS_FUNCTION_PRE_EP_ENTRIES 2 | 436 | #define FSG_HS_FUNCTION_PRE_EP_ENTRIES 2 |
406 | 437 | ||
407 | /* Maxpacket and other transfer characteristics vary by speed. */ | 438 | /* Maxpacket and other transfer characteristics vary by speed. */ |
408 | static struct usb_endpoint_descriptor * | 439 | static struct usb_endpoint_descriptor * |
409 | ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs, | 440 | fsg_ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs, |
410 | struct usb_endpoint_descriptor *hs) | 441 | struct usb_endpoint_descriptor *hs) |
411 | { | 442 | { |
412 | if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) | 443 | if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) |
@@ -415,24 +446,19 @@ ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs, | |||
415 | } | 446 | } |
416 | 447 | ||
417 | 448 | ||
418 | /* The CBI specification limits the serial string to 12 uppercase hexadecimal | ||
419 | * characters. */ | ||
420 | static char manufacturer[64]; | ||
421 | static char serial[13]; | ||
422 | |||
423 | /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ | 449 | /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ |
424 | static struct usb_string strings[] = { | 450 | static struct usb_string fsg_strings[] = { |
425 | {STRING_MANUFACTURER, manufacturer}, | 451 | {FSG_STRING_MANUFACTURER, fsg_string_manufacturer}, |
426 | {STRING_PRODUCT, longname}, | 452 | {FSG_STRING_PRODUCT, fsg_string_product}, |
427 | {STRING_SERIAL, serial}, | 453 | {FSG_STRING_SERIAL, fsg_string_serial}, |
428 | {STRING_CONFIG, "Self-powered"}, | 454 | {FSG_STRING_CONFIG, fsg_string_config}, |
429 | {STRING_INTERFACE, "Mass Storage"}, | 455 | {FSG_STRING_INTERFACE, fsg_string_interface}, |
430 | {} | 456 | {} |
431 | }; | 457 | }; |
432 | 458 | ||
433 | static struct usb_gadget_strings stringtab = { | 459 | static struct usb_gadget_strings fsg_stringtab = { |
434 | .language = 0x0409, // en-us | 460 | .language = 0x0409, // en-us |
435 | .strings = strings, | 461 | .strings = fsg_strings, |
436 | }; | 462 | }; |
437 | 463 | ||
438 | 464 | ||
@@ -441,7 +467,7 @@ static struct usb_gadget_strings stringtab = { | |||
441 | /* If the next two routines are called while the gadget is registered, | 467 | /* If the next two routines are called while the gadget is registered, |
442 | * the caller must own fsg->filesem for writing. */ | 468 | * the caller must own fsg->filesem for writing. */ |
443 | 469 | ||
444 | static int open_backing_file(struct lun *curlun, const char *filename) | 470 | static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) |
445 | { | 471 | { |
446 | int ro; | 472 | int ro; |
447 | struct file *filp = NULL; | 473 | struct file *filp = NULL; |
@@ -525,7 +551,7 @@ out: | |||
525 | } | 551 | } |
526 | 552 | ||
527 | 553 | ||
528 | static void close_backing_file(struct lun *curlun) | 554 | static void fsg_lun_close(struct fsg_lun *curlun) |
529 | { | 555 | { |
530 | if (curlun->filp) { | 556 | if (curlun->filp) { |
531 | LDBG(curlun, "close backing file\n"); | 557 | LDBG(curlun, "close backing file\n"); |
@@ -539,7 +565,7 @@ static void close_backing_file(struct lun *curlun) | |||
539 | 565 | ||
540 | /* Sync the file data, don't bother with the metadata. | 566 | /* Sync the file data, don't bother with the metadata. |
541 | * This code was copied from fs/buffer.c:sys_fdatasync(). */ | 567 | * This code was copied from fs/buffer.c:sys_fdatasync(). */ |
542 | static int fsync_sub(struct lun *curlun) | 568 | static int fsg_lun_fsync_sub(struct fsg_lun *curlun) |
543 | { | 569 | { |
544 | struct file *filp = curlun->filp; | 570 | struct file *filp = curlun->filp; |
545 | 571 | ||