diff options
author | Tejun Heo <htejun@gmail.com> | 2007-08-18 00:14:55 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-10-12 14:55:37 -0400 |
commit | cbcdd87593a1d85c5c4b259945a3a09eee12814d (patch) | |
tree | ee03df963a12ec7f30f6c3a8742421daf2c34f50 /drivers/ata/libata-eh.c | |
parent | e923090ddd9fef1d4e06dc6c5295e29baced19f3 (diff) |
libata: implement and use ata_port_desc() to report port configuration
Currently, port configuration reporting has the following problems.
* iomapped address is reported instead of raw address
* report contains irrelevant fields or lacks necessary fields for
non-SFF controllers.
* host->irq/irq2 are there just for reporting and hacky.
This patch implements and uses ata_port_desc() and
ata_port_pbar_desc(). ata_port_desc() is almost identical to
ata_ehi_push_desc() except that it takes @ap instead of @ehi, has no
locking requirement, can only be used during host initialization and "
" is used as separator instead of ", ". ata_port_pbar_desc() is a
helper to ease reporting of a PCI BAR or an offsetted address into it.
LLD pushes whatever description it wants using the above two
functions. The accumulated description is printed on host
registration after "[S/P]ATA max MAX_XFERMODE ".
SFF init helpers and ata_host_activate() automatically add
descriptions for addresses and irq respectively, so only LLDs which
isn't standard SFF need to add custom descriptions. In many cases,
such controllers need to report different things anyway.
Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-eh.c')
-rw-r--r-- | drivers/ata/libata-eh.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 2ddc2ed9c29d..8219e2d71045 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -151,6 +151,73 @@ void ata_ehi_clear_desc(struct ata_eh_info *ehi) | |||
151 | ehi->desc_len = 0; | 151 | ehi->desc_len = 0; |
152 | } | 152 | } |
153 | 153 | ||
154 | /** | ||
155 | * ata_port_desc - append port description | ||
156 | * @ap: target ATA port | ||
157 | * @fmt: printf format string | ||
158 | * | ||
159 | * Format string according to @fmt and append it to port | ||
160 | * description. If port description is not empty, " " is added | ||
161 | * in-between. This function is to be used while initializing | ||
162 | * ata_host. The description is printed on host registration. | ||
163 | * | ||
164 | * LOCKING: | ||
165 | * None. | ||
166 | */ | ||
167 | void ata_port_desc(struct ata_port *ap, const char *fmt, ...) | ||
168 | { | ||
169 | va_list args; | ||
170 | |||
171 | WARN_ON(!(ap->pflags & ATA_PFLAG_INITIALIZING)); | ||
172 | |||
173 | if (ap->link.eh_info.desc_len) | ||
174 | __ata_ehi_push_desc(&ap->link.eh_info, " "); | ||
175 | |||
176 | va_start(args, fmt); | ||
177 | __ata_ehi_pushv_desc(&ap->link.eh_info, fmt, args); | ||
178 | va_end(args); | ||
179 | } | ||
180 | |||
181 | #ifdef CONFIG_PCI | ||
182 | |||
183 | /** | ||
184 | * ata_port_pbar_desc - append PCI BAR description | ||
185 | * @ap: target ATA port | ||
186 | * @bar: target PCI BAR | ||
187 | * @offset: offset into PCI BAR | ||
188 | * @name: name of the area | ||
189 | * | ||
190 | * If @offset is negative, this function formats a string which | ||
191 | * contains the name, address, size and type of the BAR and | ||
192 | * appends it to the port description. If @offset is zero or | ||
193 | * positive, only name and offsetted address is appended. | ||
194 | * | ||
195 | * LOCKING: | ||
196 | * None. | ||
197 | */ | ||
198 | void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, | ||
199 | const char *name) | ||
200 | { | ||
201 | struct pci_dev *pdev = to_pci_dev(ap->host->dev); | ||
202 | char *type = ""; | ||
203 | unsigned long long start, len; | ||
204 | |||
205 | if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) | ||
206 | type = "m"; | ||
207 | else if (pci_resource_flags(pdev, bar) & IORESOURCE_IO) | ||
208 | type = "i"; | ||
209 | |||
210 | start = (unsigned long long)pci_resource_start(pdev, bar); | ||
211 | len = (unsigned long long)pci_resource_len(pdev, bar); | ||
212 | |||
213 | if (offset < 0) | ||
214 | ata_port_desc(ap, "%s %s%llu@0x%llx", name, type, len, start); | ||
215 | else | ||
216 | ata_port_desc(ap, "%s 0x%llx", name, start + offset); | ||
217 | } | ||
218 | |||
219 | #endif /* CONFIG_PCI */ | ||
220 | |||
154 | static void ata_ering_record(struct ata_ering *ering, int is_io, | 221 | static void ata_ering_record(struct ata_ering *ering, int is_io, |
155 | unsigned int err_mask) | 222 | unsigned int err_mask) |
156 | { | 223 | { |