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

Return to bug 281158