diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2010-06-10 02:24:35 -0400 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2010-06-10 02:24:35 -0400 |
commit | 60d32970c5a32e8c4f340a9e41993759ad658ef2 (patch) | |
tree | a7f60c934ae250f0291622cb02540638ef7cbf6d /drivers/firewire | |
parent | 3e07ec0eee1662f89e57f84aff625065beb2b209 (diff) |
firewire: add read_csr_reg driver callback
To prepare for the following additions of more OHCI-implemented CSR
registers, replace the get_cycle_time driver callback with a generic
CSR register callback.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/core-cdev.c | 2 | ||||
-rw-r--r-- | drivers/firewire/core-transaction.c | 3 | ||||
-rw-r--r-- | drivers/firewire/core.h | 2 | ||||
-rw-r--r-- | drivers/firewire/ohci.c | 19 |
4 files changed, 20 insertions, 6 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 50332b84f49a..2e62516a4b15 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c | |||
@@ -1044,7 +1044,7 @@ static int ioctl_get_cycle_timer2(struct client *client, union ioctl_arg *arg) | |||
1044 | 1044 | ||
1045 | local_irq_disable(); | 1045 | local_irq_disable(); |
1046 | 1046 | ||
1047 | cycle_time = card->driver->get_cycle_time(card); | 1047 | cycle_time = card->driver->read_csr_reg(card, CSR_CYCLE_TIME); |
1048 | 1048 | ||
1049 | switch (a->clk_id) { | 1049 | switch (a->clk_id) { |
1050 | case CLOCK_REALTIME: getnstimeofday(&ts); break; | 1050 | case CLOCK_REALTIME: getnstimeofday(&ts); break; |
diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c index 6971400b6354..a4d8109edec2 100644 --- a/drivers/firewire/core-transaction.c +++ b/drivers/firewire/core-transaction.c | |||
@@ -1025,7 +1025,8 @@ static void handle_registers(struct fw_card *card, struct fw_request *request, | |||
1025 | 1025 | ||
1026 | case CSR_CYCLE_TIME: | 1026 | case CSR_CYCLE_TIME: |
1027 | if (TCODE_IS_READ_REQUEST(tcode) && length == 4) | 1027 | if (TCODE_IS_READ_REQUEST(tcode) && length == 4) |
1028 | *data = cpu_to_be32(card->driver->get_cycle_time(card)); | 1028 | *data = cpu_to_be32(card->driver-> |
1029 | read_csr_reg(card, CSR_CYCLE_TIME)); | ||
1029 | else | 1030 | else |
1030 | rcode = RCODE_TYPE_ERROR; | 1031 | rcode = RCODE_TYPE_ERROR; |
1031 | break; | 1032 | break; |
diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h index 25a72e57a0cd..c19e9873e433 100644 --- a/drivers/firewire/core.h +++ b/drivers/firewire/core.h | |||
@@ -75,7 +75,7 @@ struct fw_card_driver { | |||
75 | int (*enable_phys_dma)(struct fw_card *card, | 75 | int (*enable_phys_dma)(struct fw_card *card, |
76 | int node_id, int generation); | 76 | int node_id, int generation); |
77 | 77 | ||
78 | u32 (*get_cycle_time)(struct fw_card *card); | 78 | u32 (*read_csr_reg)(struct fw_card *card, int csr_offset); |
79 | 79 | ||
80 | struct fw_iso_context * | 80 | struct fw_iso_context * |
81 | (*allocate_iso_context)(struct fw_card *card, | 81 | (*allocate_iso_context)(struct fw_card *card, |
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 65b9bdb8541a..a8093a9a3fc8 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -1939,9 +1939,8 @@ static u32 cycle_timer_ticks(u32 cycle_timer) | |||
1939 | * error. (A PCI read should take at least 20 ticks of the 24.576 MHz timer to | 1939 | * error. (A PCI read should take at least 20 ticks of the 24.576 MHz timer to |
1940 | * execute, so we have enough precision to compute the ratio of the differences.) | 1940 | * execute, so we have enough precision to compute the ratio of the differences.) |
1941 | */ | 1941 | */ |
1942 | static u32 ohci_get_cycle_time(struct fw_card *card) | 1942 | static u32 get_cycle_time(struct fw_ohci *ohci) |
1943 | { | 1943 | { |
1944 | struct fw_ohci *ohci = fw_ohci(card); | ||
1945 | u32 c0, c1, c2; | 1944 | u32 c0, c1, c2; |
1946 | u32 t0, t1, t2; | 1945 | u32 t0, t1, t2; |
1947 | s32 diff01, diff12; | 1946 | s32 diff01, diff12; |
@@ -1970,6 +1969,20 @@ static u32 ohci_get_cycle_time(struct fw_card *card) | |||
1970 | return c2; | 1969 | return c2; |
1971 | } | 1970 | } |
1972 | 1971 | ||
1972 | static u32 ohci_read_csr_reg(struct fw_card *card, int csr_offset) | ||
1973 | { | ||
1974 | struct fw_ohci *ohci = fw_ohci(card); | ||
1975 | |||
1976 | switch (csr_offset) { | ||
1977 | case CSR_CYCLE_TIME: | ||
1978 | return get_cycle_time(ohci); | ||
1979 | |||
1980 | default: | ||
1981 | WARN_ON(1); | ||
1982 | return 0; | ||
1983 | } | ||
1984 | } | ||
1985 | |||
1973 | static void copy_iso_headers(struct iso_context *ctx, void *p) | 1986 | static void copy_iso_headers(struct iso_context *ctx, void *p) |
1974 | { | 1987 | { |
1975 | int i = ctx->header_length; | 1988 | int i = ctx->header_length; |
@@ -2407,7 +2420,7 @@ static const struct fw_card_driver ohci_driver = { | |||
2407 | .send_response = ohci_send_response, | 2420 | .send_response = ohci_send_response, |
2408 | .cancel_packet = ohci_cancel_packet, | 2421 | .cancel_packet = ohci_cancel_packet, |
2409 | .enable_phys_dma = ohci_enable_phys_dma, | 2422 | .enable_phys_dma = ohci_enable_phys_dma, |
2410 | .get_cycle_time = ohci_get_cycle_time, | 2423 | .read_csr_reg = ohci_read_csr_reg, |
2411 | 2424 | ||
2412 | .allocate_iso_context = ohci_allocate_iso_context, | 2425 | .allocate_iso_context = ohci_allocate_iso_context, |
2413 | .free_iso_context = ohci_free_iso_context, | 2426 | .free_iso_context = ohci_free_iso_context, |