Randy, please do _not_ apply this patch.
While there are a few good things here (moving my_host_number up a few
lines and making the master spinlock static), the other changes I don't
like.
I always typedef function pointers. It's too hard to read otherwise, and
it's even harder to get the comments in the right place without them.
Also, removing the {} on if clauses with only one element is contrary to
the kernel coding convention document. I realize I'm inconsistant on this
point, but this fix goes in the wrong direction.
And finally, I don't like having the registration data structure at the
end. It makes it too hard to find for people who are looking for it.
Matt Dharm
On Fri, 31 Mar 2000, Pavel Machek wrote:
> Hi!
>
> I try to make code more readable... So typedefs with just one use are
> gone, spinlock is now static and usb_driver is moved to the end so
> that no prototypes are needed. Please apply,
>
> Pavel
>
> --- usb-storage.c.ofic Fri Mar 31 23:12:25 2000
> +++ usb-storage.c Fri Mar 31 23:17:35 2000
> @@ -53,18 +53,12 @@
> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> };
>
> +static int my_host_number = 0;
> +
> /*
> * Per device data
> */
>
> -static int my_host_number;
> -
> -struct us_data;
> -
> -typedef int (*trans_cmnd)(Scsi_Cmnd*, struct us_data*);
> -typedef int (*trans_reset)(struct us_data*);
> -typedef void (*proto_cmnd)(Scsi_Cmnd*, struct us_data*);
> -
> /* we allocate one of these for every device that we remember */
> struct us_data {
> struct us_data *next; /* next device */
> @@ -84,9 +78,9 @@
> __u8 protocol;
>
> /* function pointers for this device */
> - trans_cmnd transport; /* transport function */
> - trans_reset transport_reset; /* transport device reset */
> - proto_cmnd proto_handler; /* protocol handler */
> + int (*transport)(Scsi_Cmnd*, struct us_data*); /*
>transport function */
> + int (*transport_reset)(struct us_data*); /*
>transport device reset */
> + int (*proto_handler)(Scsi_Cmnd*, struct us_data*); /*
>protocol handler */
>
> /* SCSI interfaces */
> GUID(guid); /* unique dev id */
> @@ -127,16 +121,7 @@
>
> /* The list of structures and the protective lock for them */
> static struct us_data *us_list;
> -spinlock_t us_list_spinlock = SPIN_LOCK_UNLOCKED;
> -
> -static void * storage_probe(struct usb_device *dev, unsigned int ifnum);
> -static void storage_disconnect(struct usb_device *dev, void *ptr);
> -static struct usb_driver storage_driver = {
> - "usb-storage",
> - storage_probe,
> - storage_disconnect,
> - { NULL, NULL }
> -};
> +static spinlock_t us_list_spinlock = SPIN_LOCK_UNLOCKED;
>
> /***********************************************************************
> * Data transfer routines
> @@ -174,16 +159,14 @@
> }
>
> /* did we send all the data? */
> - if (partial == length) {
> + if (partial == length)
> return US_BULK_TRANSFER_GOOD;
> - }
>
> /* uh oh... we have an error code, so something went wrong. */
> if (result) {
> /* NAK - that means we've retried a few times allready */
> - if (result == -ETIMEDOUT) {
> + if (result == -ETIMEDOUT)
> US_DEBUGP("us_bulk_transfer: device NAKed\n");
> - }
> return US_BULK_TRANSFER_FAILED;
> }
>
> @@ -1871,6 +1854,12 @@
> spin_unlock_irqrestore(&(ss->dev_spinlock), flags);
> }
>
> +static struct usb_driver storage_driver = {
> + "usb-storage",
> + storage_probe,
> + storage_disconnect,
> + { NULL, NULL }
> +};
>
> /***********************************************************************
> * Initialization and registration
>
>
--
Matthew Dharm Home: [EMAIL PROTECTED]
Engineer, Qualcomm, Inc. Work: [EMAIL PROTECTED]
It's not that hard. No matter what the problem is, tell the customer
to reinstall Windows.
-- Nurse
User Friendly, 3/22/1998
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]