View | Details | Raw Unified | Return to bug 281158 | Differences between
and this patch

Collapse All | Expand All

(-)b/usr.sbin/mfiutil/mfi_flash.c (-9 / +23 lines)
Lines 131-139 flash_adapter(int ac, char **av) Link Here
131
131
132
	/* First, ask the firmware to allocate space for the flash file. */
132
	/* First, ask the firmware to allocate space for the flash file. */
133
	mbox_store_word(mbox, sb.st_size);
133
	mbox_store_word(mbox, sb.st_size);
134
	mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_OPEN, NULL, 0, mbox, 4, &status);
134
	if (mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_OPEN, NULL, 0, mbox, 4, &status) < 0) {
135
		error = errno;
136
		warn("Failed to allocate flash memory");
137
		goto error;
138
	}
135
	if (status != MFI_STAT_OK) {
139
	if (status != MFI_STAT_OK) {
136
		warnx("Failed to alloc flash memory: %s", mfi_status(status));
140
		warnx("Failed to allocate flash memory: %s", mfi_status(status));
137
		error = EIO;
141
		error = EIO;
138
		goto error;
142
		goto error;
139
	}
143
	}
Lines 150-166 flash_adapter(int ac, char **av) Link Here
150
		nread = read(flash, buf, FLASH_BUF_SIZE);
154
		nread = read(flash, buf, FLASH_BUF_SIZE);
151
		if (nread <= 0 || nread % 1024 != 0) {
155
		if (nread <= 0 || nread % 1024 != 0) {
152
			warnx("Bad read from flash file");
156
			warnx("Bad read from flash file");
153
			mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_CLOSE, NULL, 0,
157
			if (mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_CLOSE, NULL, 0,
154
			    NULL, 0, NULL);
158
			    NULL, 0, NULL) < 0) {
159
				warn("Failed to discard flash memory");
160
			}
155
			error = ENXIO;
161
			error = ENXIO;
156
			goto error;
162
			goto error;
157
		}
163
		}
158
164
159
		mbox_store_word(mbox, offset);
165
		mbox_store_word(mbox, offset);
160
		mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_DOWNLOAD, buf, nread,
166
		if (mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_DOWNLOAD, buf, nread,
161
		    mbox, 4, &status);
167
		    mbox, 4, &status) < 0) {
168
			error = errno;
169
			warn("Failed to download firmware");
170
			goto error;
171
		}
162
		if (status != MFI_STAT_OK) {
172
		if (status != MFI_STAT_OK) {
163
			warnx("Flash download failed: %s", mfi_status(status));
173
			warnx("Failed to download firmware: %s", mfi_status(status));
164
			mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_CLOSE, NULL, 0,
174
			mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_CLOSE, NULL, 0,
165
			    NULL, 0, NULL);
175
			    NULL, 0, NULL);
166
			error = ENXIO;
176
			error = ENXIO;
Lines 173-180 flash_adapter(int ac, char **av) Link Here
173
	/* Kick off the flash. */
183
	/* Kick off the flash. */
174
	printf("WARNING: Firmware flash in progress, do not reboot machine... ");
184
	printf("WARNING: Firmware flash in progress, do not reboot machine... ");
175
	fflush(stdout);
185
	fflush(stdout);
176
	mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_FLASH, &dummy, sizeof(dummy),
186
	if (mfi_dcmd_command(fd, MFI_DCMD_FLASH_FW_FLASH, &dummy, sizeof(dummy),
177
	    NULL, 0, &status);
187
	    NULL, 0, &status) < 0) {
188
		error = errno;
189
		printf("failed:\n\t%s\n", strerror(error));
190
		goto error;
191
	}
178
	if (status != MFI_STAT_OK) {
192
	if (status != MFI_STAT_OK) {
179
		printf("failed:\n\t%s\n", mfi_status(status));
193
		printf("failed:\n\t%s\n", mfi_status(status));
180
		error = ENXIO;
194
		error = ENXIO;

Return to bug 281158