Linux Audio

Check our new training course

Loading...
v3.1
  1/*
  2 * Copyright (c) 2000-2001 Adaptec Inc.
  3 * All rights reserved.
  4 *
  5 * Redistribution and use in source and binary forms, with or without
  6 * modification, are permitted provided that the following conditions
  7 * are met:
  8 * 1. Redistributions of source code must retain the above copyright
  9 *    notice, this list of conditions, and the following disclaimer,
 10 *    without modification.
 11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 12 *    substantially similar to the "NO WARRANTY" disclaimer below
 13 *    ("Disclaimer") and any redistribution must be conditioned upon
 14 *    including a substantially similar Disclaimer requirement for further
 15 *    binary redistribution.
 16 * 3. Neither the names of the above-listed copyright holders nor the names
 17 *    of any contributors may be used to endorse or promote products derived
 18 *    from this software without specific prior written permission.
 19 *
 20 * Alternatively, this software may be distributed under the terms of the
 21 * GNU General Public License ("GPL") version 2 as published by the Free
 22 * Software Foundation.
 23 *
 24 * NO WARRANTY
 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 29 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 34 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 35 * POSSIBILITY OF SUCH DAMAGES.
 36 *
 37 * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
 38 * sym driver.
 39 *
 40 * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#19 $
 41 */
 42#include "aic79xx_osm.h"
 43#include "aic79xx_inline.h"
 44
 45static void	copy_mem_info(struct info_str *info, char *data, int len);
 46static int	copy_info(struct info_str *info, char *fmt, ...);
 47static void	ahd_dump_target_state(struct ahd_softc *ahd,
 48				      struct info_str *info,
 49				      u_int our_id, char channel,
 50				      u_int target_id);
 51static void	ahd_dump_device_state(struct info_str *info,
 52				      struct scsi_device *sdev);
 53static int	ahd_proc_write_seeprom(struct ahd_softc *ahd,
 54				       char *buffer, int length);
 55
 56/*
 57 * Table of syncrates that don't follow the "divisible by 4"
 58 * rule. This table will be expanded in future SCSI specs.
 59 */
 60static const struct {
 61	u_int period_factor;
 62	u_int period;	/* in 100ths of ns */
 63} scsi_syncrates[] = {
 64	{ 0x08, 625 },	/* FAST-160 */
 65	{ 0x09, 1250 },	/* FAST-80 */
 66	{ 0x0a, 2500 },	/* FAST-40 40MHz */
 67	{ 0x0b, 3030 },	/* FAST-40 33MHz */
 68	{ 0x0c, 5000 }	/* FAST-20 */
 69};
 70
 71/*
 72 * Return the frequency in kHz corresponding to the given
 73 * sync period factor.
 74 */
 75static u_int
 76ahd_calc_syncsrate(u_int period_factor)
 77{
 78	int i;
 79
 80	/* See if the period is in the "exception" table */
 81	for (i = 0; i < ARRAY_SIZE(scsi_syncrates); i++) {
 82
 83		if (period_factor == scsi_syncrates[i].period_factor) {
 84			/* Period in kHz */
 85			return (100000000 / scsi_syncrates[i].period);
 86		}
 87	}
 88
 89	/*
 90	 * Wasn't in the table, so use the standard
 91	 * 4 times conversion.
 92	 */
 93	return (10000000 / (period_factor * 4 * 10));
 94}
 95
 96
 97static void
 98copy_mem_info(struct info_str *info, char *data, int len)
 99{
100	if (info->pos + len > info->offset + info->length)
101		len = info->offset + info->length - info->pos;
102
103	if (info->pos + len < info->offset) {
104		info->pos += len;
105		return;
106	}
107
108	if (info->pos < info->offset) {
109		off_t partial;
110
111		partial = info->offset - info->pos;
112		data += partial;
113		info->pos += partial;
114		len  -= partial;
115	}
116
117	if (len > 0) {
118		memcpy(info->buffer, data, len);
119		info->pos += len;
120		info->buffer += len;
121	}
122}
123
124static int
125copy_info(struct info_str *info, char *fmt, ...)
126{
127	va_list args;
128	char buf[256];
129	int len;
130
131	va_start(args, fmt);
132	len = vsprintf(buf, fmt, args);
133	va_end(args);
134
135	copy_mem_info(info, buf, len);
136	return (len);
137}
138
139static void
140ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
141{
142	u_int speed;
143	u_int freq;
144	u_int mb;
145
146	if (tinfo->period == AHD_PERIOD_UNKNOWN) {
147		copy_info(info, "Renegotiation Pending\n");
148		return;
149	}
150        speed = 3300;
151        freq = 0;
152	if (tinfo->offset != 0) {
153		freq = ahd_calc_syncsrate(tinfo->period);
154		speed = freq;
155	}
156	speed *= (0x01 << tinfo->width);
157        mb = speed / 1000;
158        if (mb > 0)
159		copy_info(info, "%d.%03dMB/s transfers", mb, speed % 1000);
160        else
161		copy_info(info, "%dKB/s transfers", speed);
162
163	if (freq != 0) {
164		int	printed_options;
165
166		printed_options = 0;
167		copy_info(info, " (%d.%03dMHz", freq / 1000, freq % 1000);
168		if ((tinfo->ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
169			copy_info(info, " RDSTRM");
170			printed_options++;
171		}
172		if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
173			copy_info(info, "%s", printed_options ? "|DT" : " DT");
174			printed_options++;
175		}
176		if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
177			copy_info(info, "%s", printed_options ? "|IU" : " IU");
178			printed_options++;
179		}
180		if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) {
181			copy_info(info, "%s",
182				  printed_options ? "|RTI" : " RTI");
183			printed_options++;
184		}
185		if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
186			copy_info(info, "%s",
187				  printed_options ? "|QAS" : " QAS");
188			printed_options++;
189		}
190	}
191
192	if (tinfo->width > 0) {
193		if (freq != 0) {
194			copy_info(info, ", ");
195		} else {
196			copy_info(info, " (");
197		}
198		copy_info(info, "%dbit)", 8 * (0x01 << tinfo->width));
199	} else if (freq != 0) {
200		copy_info(info, ")");
201	}
202	copy_info(info, "\n");
203}
204
205static void
206ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info,
207		      u_int our_id, char channel, u_int target_id)
208{
209	struct  scsi_target *starget;
210	struct	ahd_initiator_tinfo *tinfo;
211	struct	ahd_tmode_tstate *tstate;
212	int	lun;
213
214	tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
215				    target_id, &tstate);
216	copy_info(info, "Target %d Negotiation Settings\n", target_id);
217	copy_info(info, "\tUser: ");
218	ahd_format_transinfo(info, &tinfo->user);
219	starget = ahd->platform_data->starget[target_id];
220	if (starget == NULL)
221		return;
222
223	copy_info(info, "\tGoal: ");
224	ahd_format_transinfo(info, &tinfo->goal);
225	copy_info(info, "\tCurr: ");
226	ahd_format_transinfo(info, &tinfo->curr);
227
228	for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
229		struct scsi_device *dev;
230
231		dev = scsi_device_lookup_by_target(starget, lun);
232
233		if (dev == NULL)
234			continue;
235
236		ahd_dump_device_state(info, dev);
237	}
238}
239
240static void
241ahd_dump_device_state(struct info_str *info, struct scsi_device *sdev)
242{
243	struct ahd_linux_device *dev = scsi_transport_device_data(sdev);
244
245	copy_info(info, "\tChannel %c Target %d Lun %d Settings\n",
246		  sdev->sdev_target->channel + 'A',
247		  sdev->sdev_target->id, sdev->lun);
248
249	copy_info(info, "\t\tCommands Queued %ld\n", dev->commands_issued);
250	copy_info(info, "\t\tCommands Active %d\n", dev->active);
251	copy_info(info, "\t\tCommand Openings %d\n", dev->openings);
252	copy_info(info, "\t\tMax Tagged Openings %d\n", dev->maxtags);
253	copy_info(info, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen);
254}
255
256static int
257ahd_proc_write_seeprom(struct ahd_softc *ahd, char *buffer, int length)
258{
 
259	ahd_mode_state saved_modes;
260	int have_seeprom;
261	u_long s;
262	int paused;
263	int written;
264
265	/* Default to failure. */
266	written = -EINVAL;
267	ahd_lock(ahd, &s);
268	paused = ahd_is_paused(ahd);
269	if (!paused)
270		ahd_pause(ahd);
271
272	saved_modes = ahd_save_modes(ahd);
273	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
274	if (length != sizeof(struct seeprom_config)) {
275		printk("ahd_proc_write_seeprom: incorrect buffer size\n");
276		goto done;
277	}
278
279	have_seeprom = ahd_verify_cksum((struct seeprom_config*)buffer);
280	if (have_seeprom == 0) {
281		printk("ahd_proc_write_seeprom: cksum verification failed\n");
282		goto done;
283	}
284
285	have_seeprom = ahd_acquire_seeprom(ahd);
286	if (!have_seeprom) {
287		printk("ahd_proc_write_seeprom: No Serial EEPROM\n");
288		goto done;
289	} else {
290		u_int start_addr;
291
292		if (ahd->seep_config == NULL) {
293			ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC);
 
294			if (ahd->seep_config == NULL) {
295				printk("aic79xx: Unable to allocate serial "
296				       "eeprom buffer.  Write failing\n");
297				goto done;
298			}
299		}
300		printk("aic79xx: Writing Serial EEPROM\n");
301		start_addr = 32 * (ahd->channel - 'A');
302		ahd_write_seeprom(ahd, (u_int16_t *)buffer, start_addr,
303				  sizeof(struct seeprom_config)/2);
304		ahd_read_seeprom(ahd, (uint16_t *)ahd->seep_config,
305				 start_addr, sizeof(struct seeprom_config)/2,
306				 /*ByteStream*/FALSE);
307		ahd_release_seeprom(ahd);
308		written = length;
309	}
310
311done:
312	ahd_restore_modes(ahd, saved_modes);
313	if (!paused)
314		ahd_unpause(ahd);
315	ahd_unlock(ahd, &s);
316	return (written);
317}
318/*
319 * Return information to handle /proc support for the driver.
320 */
321int
322ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
323		    off_t offset, int length, int inout)
324{
325	struct	ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
326	struct	info_str info;
327	char	ahd_info[256];
328	u_int	max_targ;
329	u_int	i;
330	int	retval;
331
332	 /* Has data been written to the file? */ 
333	if (inout == TRUE) {
334		retval = ahd_proc_write_seeprom(ahd, buffer, length);
335		goto done;
336	}
337
338	if (start)
339		*start = buffer;
340
341	info.buffer	= buffer;
342	info.length	= length;
343	info.offset	= offset;
344	info.pos	= 0;
345
346	copy_info(&info, "Adaptec AIC79xx driver version: %s\n",
347		  AIC79XX_DRIVER_VERSION);
348	copy_info(&info, "%s\n", ahd->description);
349	ahd_controller_info(ahd, ahd_info);
350	copy_info(&info, "%s\n", ahd_info);
351	copy_info(&info, "Allocated SCBs: %d, SG List Length: %d\n\n",
352		  ahd->scb_data.numscbs, AHD_NSEG);
353
354	max_targ = 16;
355
356	if (ahd->seep_config == NULL)
357		copy_info(&info, "No Serial EEPROM\n");
358	else {
359		copy_info(&info, "Serial EEPROM:\n");
360		for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) {
361			if (((i % 8) == 0) && (i != 0)) {
362				copy_info(&info, "\n");
363			}
364			copy_info(&info, "0x%.4x ",
365				  ((uint16_t*)ahd->seep_config)[i]);
366		}
367		copy_info(&info, "\n");
368	}
369	copy_info(&info, "\n");
370
371	if ((ahd->features & AHD_WIDE) == 0)
372		max_targ = 8;
373
374	for (i = 0; i < max_targ; i++) {
375
376		ahd_dump_target_state(ahd, &info, ahd->our_id, 'A',
377				      /*target_id*/i);
378	}
379	retval = info.pos > info.offset ? info.pos - info.offset : 0;
380done:
381	return (retval);
382}
v6.9.4
  1/*
  2 * Copyright (c) 2000-2001 Adaptec Inc.
  3 * All rights reserved.
  4 *
  5 * Redistribution and use in source and binary forms, with or without
  6 * modification, are permitted provided that the following conditions
  7 * are met:
  8 * 1. Redistributions of source code must retain the above copyright
  9 *    notice, this list of conditions, and the following disclaimer,
 10 *    without modification.
 11 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 12 *    substantially similar to the "NO WARRANTY" disclaimer below
 13 *    ("Disclaimer") and any redistribution must be conditioned upon
 14 *    including a substantially similar Disclaimer requirement for further
 15 *    binary redistribution.
 16 * 3. Neither the names of the above-listed copyright holders nor the names
 17 *    of any contributors may be used to endorse or promote products derived
 18 *    from this software without specific prior written permission.
 19 *
 20 * Alternatively, this software may be distributed under the terms of the
 21 * GNU General Public License ("GPL") version 2 as published by the Free
 22 * Software Foundation.
 23 *
 24 * NO WARRANTY
 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 29 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 34 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 35 * POSSIBILITY OF SUCH DAMAGES.
 36 *
 37 * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
 38 * sym driver.
 39 *
 40 * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#19 $
 41 */
 42#include "aic79xx_osm.h"
 43#include "aic79xx_inline.h"
 44
 
 
 45static void	ahd_dump_target_state(struct ahd_softc *ahd,
 46				      struct seq_file *m,
 47				      u_int our_id, char channel,
 48				      u_int target_id);
 49static void	ahd_dump_device_state(struct seq_file *m,
 50				      struct scsi_device *sdev);
 
 
 51
 52/*
 53 * Table of syncrates that don't follow the "divisible by 4"
 54 * rule. This table will be expanded in future SCSI specs.
 55 */
 56static const struct {
 57	u_int period_factor;
 58	u_int period;	/* in 100ths of ns */
 59} scsi_syncrates[] = {
 60	{ 0x08, 625 },	/* FAST-160 */
 61	{ 0x09, 1250 },	/* FAST-80 */
 62	{ 0x0a, 2500 },	/* FAST-40 40MHz */
 63	{ 0x0b, 3030 },	/* FAST-40 33MHz */
 64	{ 0x0c, 5000 }	/* FAST-20 */
 65};
 66
 67/*
 68 * Return the frequency in kHz corresponding to the given
 69 * sync period factor.
 70 */
 71static u_int
 72ahd_calc_syncsrate(u_int period_factor)
 73{
 74	int i;
 75
 76	/* See if the period is in the "exception" table */
 77	for (i = 0; i < ARRAY_SIZE(scsi_syncrates); i++) {
 78
 79		if (period_factor == scsi_syncrates[i].period_factor) {
 80			/* Period in kHz */
 81			return (100000000 / scsi_syncrates[i].period);
 82		}
 83	}
 84
 85	/*
 86	 * Wasn't in the table, so use the standard
 87	 * 4 times conversion.
 88	 */
 89	return (10000000 / (period_factor * 4 * 10));
 90}
 91
 
 92static void
 93ahd_format_transinfo(struct seq_file *m, struct ahd_transinfo *tinfo)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 94{
 95	u_int speed;
 96	u_int freq;
 97	u_int mb;
 98
 99	if (tinfo->period == AHD_PERIOD_UNKNOWN) {
100		seq_puts(m, "Renegotiation Pending\n");
101		return;
102	}
103	speed = 3300;
104	freq = 0;
105	if (tinfo->offset != 0) {
106		freq = ahd_calc_syncsrate(tinfo->period);
107		speed = freq;
108	}
109	speed *= (0x01 << tinfo->width);
110	mb = speed / 1000;
111	if (mb > 0)
112		seq_printf(m, "%d.%03dMB/s transfers", mb, speed % 1000);
113	else
114		seq_printf(m, "%dKB/s transfers", speed);
115
116	if (freq != 0) {
117		int	printed_options;
118
119		printed_options = 0;
120		seq_printf(m, " (%d.%03dMHz", freq / 1000, freq % 1000);
121		if ((tinfo->ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
122			seq_puts(m, " RDSTRM");
123			printed_options++;
124		}
125		if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
126			seq_puts(m, printed_options ? "|DT" : " DT");
127			printed_options++;
128		}
129		if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
130			seq_puts(m, printed_options ? "|IU" : " IU");
131			printed_options++;
132		}
133		if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) {
134			seq_puts(m, printed_options ? "|RTI" : " RTI");
 
135			printed_options++;
136		}
137		if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
138			seq_puts(m, printed_options ? "|QAS" : " QAS");
 
139			printed_options++;
140		}
141	}
142
143	if (tinfo->width > 0) {
144		if (freq != 0) {
145			seq_puts(m, ", ");
146		} else {
147			seq_puts(m, " (");
148		}
149		seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
150	} else if (freq != 0) {
151		seq_putc(m, ')');
152	}
153	seq_putc(m, '\n');
154}
155
156static void
157ahd_dump_target_state(struct ahd_softc *ahd, struct seq_file *m,
158		      u_int our_id, char channel, u_int target_id)
159{
160	struct  scsi_target *starget;
161	struct	ahd_initiator_tinfo *tinfo;
162	struct	ahd_tmode_tstate *tstate;
163	int	lun;
164
165	tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
166				    target_id, &tstate);
167	seq_printf(m, "Target %d Negotiation Settings\n", target_id);
168	seq_puts(m, "\tUser: ");
169	ahd_format_transinfo(m, &tinfo->user);
170	starget = ahd->platform_data->starget[target_id];
171	if (starget == NULL)
172		return;
173
174	seq_puts(m, "\tGoal: ");
175	ahd_format_transinfo(m, &tinfo->goal);
176	seq_puts(m, "\tCurr: ");
177	ahd_format_transinfo(m, &tinfo->curr);
178
179	for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
180		struct scsi_device *dev;
181
182		dev = scsi_device_lookup_by_target(starget, lun);
183
184		if (dev == NULL)
185			continue;
186
187		ahd_dump_device_state(m, dev);
188	}
189}
190
191static void
192ahd_dump_device_state(struct seq_file *m, struct scsi_device *sdev)
193{
194	struct ahd_linux_device *dev = scsi_transport_device_data(sdev);
195
196	seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
197		  sdev->sdev_target->channel + 'A',
198		   sdev->sdev_target->id, (u8)sdev->lun);
199
200	seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
201	seq_printf(m, "\t\tCommands Active %d\n", dev->active);
202	seq_printf(m, "\t\tCommand Openings %d\n", dev->openings);
203	seq_printf(m, "\t\tMax Tagged Openings %d\n", dev->maxtags);
204	seq_printf(m, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen);
205}
206
207int
208ahd_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length)
209{
210	struct	ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
211	ahd_mode_state saved_modes;
212	int have_seeprom;
213	u_long s;
214	int paused;
215	int written;
216
217	/* Default to failure. */
218	written = -EINVAL;
219	ahd_lock(ahd, &s);
220	paused = ahd_is_paused(ahd);
221	if (!paused)
222		ahd_pause(ahd);
223
224	saved_modes = ahd_save_modes(ahd);
225	ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
226	if (length != sizeof(struct seeprom_config)) {
227		printk("ahd_proc_write_seeprom: incorrect buffer size\n");
228		goto done;
229	}
230
231	have_seeprom = ahd_verify_cksum((struct seeprom_config*)buffer);
232	if (have_seeprom == 0) {
233		printk("ahd_proc_write_seeprom: cksum verification failed\n");
234		goto done;
235	}
236
237	have_seeprom = ahd_acquire_seeprom(ahd);
238	if (!have_seeprom) {
239		printk("ahd_proc_write_seeprom: No Serial EEPROM\n");
240		goto done;
241	} else {
242		u_int start_addr;
243
244		if (ahd->seep_config == NULL) {
245			ahd->seep_config = kmalloc(sizeof(*ahd->seep_config),
246						   GFP_ATOMIC);
247			if (ahd->seep_config == NULL) {
248				printk("aic79xx: Unable to allocate serial "
249				       "eeprom buffer.  Write failing\n");
250				goto done;
251			}
252		}
253		printk("aic79xx: Writing Serial EEPROM\n");
254		start_addr = 32 * (ahd->channel - 'A');
255		ahd_write_seeprom(ahd, (u_int16_t *)buffer, start_addr,
256				  sizeof(struct seeprom_config)/2);
257		ahd_read_seeprom(ahd, (uint16_t *)ahd->seep_config,
258				 start_addr, sizeof(struct seeprom_config)/2,
259				 /*ByteStream*/FALSE);
260		ahd_release_seeprom(ahd);
261		written = length;
262	}
263
264done:
265	ahd_restore_modes(ahd, saved_modes);
266	if (!paused)
267		ahd_unpause(ahd);
268	ahd_unlock(ahd, &s);
269	return (written);
270}
271/*
272 * Return information to handle /proc support for the driver.
273 */
274int
275ahd_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)
 
276{
277	struct	ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
 
278	char	ahd_info[256];
279	u_int	max_targ;
280	u_int	i;
 
281
282	seq_printf(m, "Adaptec AIC79xx driver version: %s\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283		  AIC79XX_DRIVER_VERSION);
284	seq_printf(m, "%s\n", ahd->description);
285	ahd_controller_info(ahd, ahd_info);
286	seq_printf(m, "%s\n", ahd_info);
287	seq_printf(m, "Allocated SCBs: %d, SG List Length: %d\n\n",
288		  ahd->scb_data.numscbs, AHD_NSEG);
289
290	max_targ = 16;
291
292	if (ahd->seep_config == NULL)
293		seq_puts(m, "No Serial EEPROM\n");
294	else {
295		seq_puts(m, "Serial EEPROM:\n");
296		for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) {
297			if (((i % 8) == 0) && (i != 0)) {
298				seq_putc(m, '\n');
299			}
300			seq_printf(m, "0x%.4x ",
301				  ((uint16_t*)ahd->seep_config)[i]);
302		}
303		seq_putc(m, '\n');
304	}
305	seq_putc(m, '\n');
306
307	if ((ahd->features & AHD_WIDE) == 0)
308		max_targ = 8;
309
310	for (i = 0; i < max_targ; i++) {
311
312		ahd_dump_target_state(ahd, m, ahd->our_id, 'A',
313				      /*target_id*/i);
314	}
315	return 0;
 
 
316}