pata_via: clean up recent tf_load changes

Commit bfce5e0179ad059035df28558724ff60af708e09 implemented custom
tf_load for pata_via. This patch cleans it up a bit.

* Instead of duplicating whole body, copy tf and set ATA_TFLAG_DEVICE
when necessary.

* Rename via_ata_tf_load() to via_tf_load().

* No need to set .tf_load in via_port_ops_noirq as it inherits from
via_port_ops.

* Clean up indentation.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Joseph Chan <JosephChan@via.com.tw>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

authored by Tejun Heo and committed by Jeff Garzik ff04715b d127ea7b

+11 -48
+11 -48
drivers/ata/pata_via.c
··· 324 324 } 325 325 326 326 /** 327 - * via_ata_sff_tf_load - send taskfile registers to host controller 327 + * via_tf_load - send taskfile registers to host controller 328 328 * @ap: Port to which output is sent 329 329 * @tf: ATA taskfile register set 330 330 * 331 331 * Outputs ATA taskfile to standard ATA host controller. 332 332 * 333 333 * Note: This is to fix the internal bug of via chipsets, which 334 - * will reset the device register after changing the IEN bit on 335 - * ctl register 334 + * will reset the device register after changing the IEN bit on 335 + * ctl register 336 336 */ 337 - static void via_ata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) 337 + static void via_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) 338 338 { 339 - struct ata_ioports *ioaddr = &ap->ioaddr; 340 - unsigned int is_addr = tf->flags & ATA_TFLAG_ISADDR; 339 + struct ata_taskfile tmp_tf; 341 340 342 - if (tf->ctl != ap->last_ctl) { 343 - iowrite8(tf->ctl, ioaddr->ctl_addr); 344 - iowrite8(tf->device, ioaddr->device_addr); 345 - ap->last_ctl = tf->ctl; 346 - ata_wait_idle(ap); 341 + if (ap->ctl != ap->last_ctl && !(tf->flags & ATA_TFLAG_DEVICE)) { 342 + tmp_tf = *tf; 343 + tmp_tf.flags |= ATA_TFLAG_DEVICE; 344 + tf = &tmp_tf; 347 345 } 348 - 349 - if (is_addr && (tf->flags & ATA_TFLAG_LBA48)) { 350 - iowrite8(tf->hob_feature, ioaddr->feature_addr); 351 - iowrite8(tf->hob_nsect, ioaddr->nsect_addr); 352 - iowrite8(tf->hob_lbal, ioaddr->lbal_addr); 353 - iowrite8(tf->hob_lbam, ioaddr->lbam_addr); 354 - iowrite8(tf->hob_lbah, ioaddr->lbah_addr); 355 - VPRINTK("hob: feat 0x%X nsect 0x%X, lba 0x%X 0x%X 0x%X\n", 356 - tf->hob_feature, 357 - tf->hob_nsect, 358 - tf->hob_lbal, 359 - tf->hob_lbam, 360 - tf->hob_lbah); 361 - } 362 - 363 - if (is_addr) { 364 - iowrite8(tf->feature, ioaddr->feature_addr); 365 - iowrite8(tf->nsect, ioaddr->nsect_addr); 366 - iowrite8(tf->lbal, ioaddr->lbal_addr); 367 - iowrite8(tf->lbam, ioaddr->lbam_addr); 368 - iowrite8(tf->lbah, ioaddr->lbah_addr); 369 - VPRINTK("feat 0x%X nsect 0x%X lba 0x%X 0x%X 0x%X\n", 370 - tf->feature, 371 - tf->nsect, 372 - tf->lbal, 373 - tf->lbam, 374 - tf->lbah); 375 - } 376 - 377 - if (tf->flags & ATA_TFLAG_DEVICE) { 378 - iowrite8(tf->device, ioaddr->device_addr); 379 - VPRINTK("device 0x%X\n", tf->device); 380 - } 381 - 382 - ata_wait_idle(ap); 346 + ata_sff_tf_load(ap, tf); 383 347 } 384 348 385 349 static struct scsi_host_template via_sht = { ··· 356 392 .set_piomode = via_set_piomode, 357 393 .set_dmamode = via_set_dmamode, 358 394 .prereset = via_pre_reset, 359 - .sff_tf_load = via_ata_tf_load, 395 + .sff_tf_load = via_tf_load, 360 396 }; 361 397 362 398 static struct ata_port_operations via_port_ops_noirq = { 363 399 .inherits = &via_port_ops, 364 400 .sff_data_xfer = ata_sff_data_xfer_noirq, 365 - .sff_tf_load = via_ata_tf_load, 366 401 }; 367 402 368 403 /**