Skip to content

Commit 2ebe1d9

Browse files
committed
ide: use try_to_identify() in ide_driveid_update()
* Pass pointer to buffer for IDENTIFY data to do_identify() and try_to_identify(). * Un-static try_to_identify() and use it in ide_driveid_update(). * Rename try_to_identify() to ide_dev_read_id(). There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent ff18b89 commit 2ebe1d9

File tree

3 files changed

+18
-62
lines changed

3 files changed

+18
-62
lines changed

drivers/ide/ide-iops.c

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -289,65 +289,19 @@ u8 eighty_ninty_three(ide_drive_t *drive)
289289

290290
int ide_driveid_update(ide_drive_t *drive)
291291
{
292-
ide_hwif_t *hwif = drive->hwif;
293-
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
294292
u16 *id;
295-
unsigned long flags;
296-
int use_altstatus = 0, rc;
297-
u8 a, uninitialized_var(s);
293+
int rc;
298294

299295
id = kmalloc(SECTOR_SIZE, GFP_ATOMIC);
300296
if (id == NULL)
301297
return 0;
302298

303-
/*
304-
* Re-read drive->id for possible DMA mode
305-
* change (copied from ide-probe.c)
306-
*/
307-
308299
SELECT_MASK(drive, 1);
309-
tp_ops->set_irq(hwif, 0);
310-
msleep(50);
311-
312-
if (hwif->io_ports.ctl_addr &&
313-
(hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) {
314-
a = tp_ops->read_altstatus(hwif);
315-
s = tp_ops->read_status(hwif);
316-
if ((a ^ s) & ~ATA_IDX)
317-
/* ancient Seagate drives, broken interfaces */
318-
printk(KERN_INFO "%s: probing with STATUS(0x%02x) "
319-
"instead of ALTSTATUS(0x%02x)\n",
320-
drive->name, s, a);
321-
else
322-
/* use non-intrusive polling */
323-
use_altstatus = 1;
324-
}
325-
326-
tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
327-
328-
if (ide_busy_sleep(hwif, WAIT_WORSTCASE / 2, use_altstatus)) {
329-
rc = 1;
330-
goto out_err;
331-
}
332-
333-
msleep(50); /* wait for IRQ and ATA_DRQ */
334-
335-
s = tp_ops->read_status(hwif);
300+
rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id);
301+
SELECT_MASK(drive, 0);
336302

337-
if (!OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
338-
rc = 2;
303+
if (rc)
339304
goto out_err;
340-
}
341-
342-
local_irq_save(flags);
343-
tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
344-
local_irq_restore(flags);
345-
346-
(void)tp_ops->read_status(hwif); /* clear drive IRQ */
347-
348-
ide_fix_driveid(id);
349-
350-
SELECT_MASK(drive, 0);
351305

352306
drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES];
353307
drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES];

drivers/ide/ide-probe.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,16 @@ static void ide_classify_atapi_dev(ide_drive_t *drive)
181181
* do_identify - identify a drive
182182
* @drive: drive to identify
183183
* @cmd: command used
184+
* @id: buffer for IDENTIFY data
184185
*
185186
* Called when we have issued a drive identify command to
186187
* read and parse the results. This function is run with
187188
* interrupts disabled.
188189
*/
189190

190-
static void do_identify(ide_drive_t *drive, u8 cmd)
191+
static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id)
191192
{
192193
ide_hwif_t *hwif = drive->hwif;
193-
u16 *id = drive->id;
194194
char *m = (char *)&id[ATA_ID_PROD];
195195
unsigned long flags;
196196
int bswap = 1;
@@ -240,19 +240,19 @@ static void do_identify(ide_drive_t *drive, u8 cmd)
240240
}
241241

242242
/**
243-
* try_to_identify - send ATA/ATAPI identify
243+
* ide_dev_read_id - send ATA/ATAPI IDENTIFY command
244244
* @drive: drive to identify
245245
* @cmd: command to use
246+
* @id: buffer for IDENTIFY data
246247
*
247-
* try_to_identify() sends an ATA(PI) IDENTIFY request to a drive
248-
* and waits for a response.
248+
* Sends an ATA(PI) IDENTIFY request to a drive and waits for a response.
249249
*
250250
* Returns: 0 device was identified
251251
* 1 device timed-out (no response to identify request)
252252
* 2 device aborted the command (refused to identify itself)
253253
*/
254254

255-
static int try_to_identify(ide_drive_t *drive, u8 cmd)
255+
int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
256256
{
257257
ide_hwif_t *hwif = drive->hwif;
258258
struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -312,7 +312,7 @@ static int try_to_identify(ide_drive_t *drive, u8 cmd)
312312

313313
if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
314314
/* drive returned ID */
315-
do_identify(drive, cmd);
315+
do_identify(drive, cmd, id);
316316
/* drive responded with ID */
317317
rc = 0;
318318
/* clear drive IRQ */
@@ -378,6 +378,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
378378
{
379379
ide_hwif_t *hwif = drive->hwif;
380380
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
381+
u16 *id = drive->id;
381382
int rc;
382383
u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat;
383384

@@ -413,11 +414,10 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
413414

414415
if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) ||
415416
present || cmd == ATA_CMD_ID_ATAPI) {
416-
/* send cmd and wait */
417-
if ((rc = try_to_identify(drive, cmd))) {
417+
rc = ide_dev_read_id(drive, cmd, id);
418+
if (rc)
418419
/* failed: try again */
419-
rc = try_to_identify(drive,cmd);
420-
}
420+
rc = ide_dev_read_id(drive, cmd, id);
421421

422422
stat = tp_ops->read_status(hwif);
423423

@@ -432,7 +432,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
432432
msleep(50);
433433
tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
434434
(void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0);
435-
rc = try_to_identify(drive, cmd);
435+
rc = ide_dev_read_id(drive, cmd, id);
436436
}
437437

438438
/* ensure drive IRQ is clear */

include/linux/ide.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,6 +1235,8 @@ int ide_no_data_taskfile(ide_drive_t *, ide_task_t *);
12351235

12361236
int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
12371237

1238+
int ide_dev_read_id(ide_drive_t *, u8, u16 *);
1239+
12381240
extern int ide_driveid_update(ide_drive_t *);
12391241
extern int ide_config_drive_speed(ide_drive_t *, u8);
12401242
extern u8 eighty_ninty_three (ide_drive_t *);

0 commit comments

Comments
 (0)