Date: Mon, 3 Jun 2013 22:06:09 +0000 (UTC) From: Steven Hartland <smh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251350 - stable/9/sys/cam/scsi Message-ID: <201306032206.r53M69tT099467@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: smh Date: Mon Jun 3 22:06:09 2013 New Revision: 251350 URL: http://svnweb.freebsd.org/changeset/base/251350 Log: MFC r249937: Refactored scsi_xpt use of device_has_vpd Modified: stable/9/sys/cam/scsi/scsi_all.c stable/9/sys/cam/scsi/scsi_all.h stable/9/sys/cam/scsi/scsi_xpt.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 21:52:19 2013 (r251349) +++ stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 22:06:09 2013 (r251350) @@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/libkern.h> #include <sys/kernel.h> +#include <sys/lock.h> +#include <sys/malloc.h> +#include <sys/mutex.h> #include <sys/sysctl.h> #else #include <errno.h> @@ -55,7 +58,13 @@ __FBSDID("$FreeBSD$"); #include <cam/scsi/scsi_all.h> #include <sys/ata.h> #include <sys/sbuf.h> -#ifndef _KERNEL + +#ifdef _KERNEL +#include <cam/cam_periph.h> +#include <cam/cam_xpt_sim.h> +#include <cam/cam_xpt_periph.h> +#include <cam/cam_xpt_internal.h> +#else #include <camlib.h> #include <stddef.h> @@ -6252,6 +6261,28 @@ scsi_devid_match(uint8_t *lhs, size_t lh } #ifdef _KERNEL +int +scsi_vpd_supported_page(struct cam_periph *periph, uint8_t page_id) +{ + struct cam_ed *device; + struct scsi_vpd_supported_pages *vpds; + int i, num_pages; + + device = periph->path->device; + vpds = (struct scsi_vpd_supported_pages *)device->supported_vpds; + + if (vpds != NULL) { + num_pages = device->supported_vpds_len - + SVPD_SUPPORTED_PAGES_HDR_LEN; + for (i = 0; i < num_pages; i++) { + if (vpds->page_list[i] == page_id) + return (1); + } + } + + return (0); +} + static void init_scsi_delay(void) { Modified: stable/9/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 21:52:19 2013 (r251349) +++ stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 22:06:09 2013 (r251350) @@ -2257,6 +2257,8 @@ int scsi_sense_sbuf(struct ccb_scsiio * char * scsi_sense_string(struct ccb_scsiio *csio, char *str, int str_len); void scsi_sense_print(struct ccb_scsiio *csio); +int scsi_vpd_supported_page(struct cam_periph *periph, + uint8_t page_id); #else /* _KERNEL */ int scsi_command_string(struct cam_device *device, struct ccb_scsiio *csio, struct sbuf *sb); Modified: stable/9/sys/cam/scsi/scsi_xpt.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_xpt.c Mon Jun 3 21:52:19 2013 (r251349) +++ stable/9/sys/cam/scsi/scsi_xpt.c Mon Jun 3 22:06:09 2013 (r251350) @@ -556,7 +556,6 @@ static const int scsi_quirk_table_size = static cam_status proberegister(struct cam_periph *periph, void *arg); static void probeschedule(struct cam_periph *probe_periph); -static int device_has_vpd(struct cam_ed *device, uint8_t page_id); static void probestart(struct cam_periph *periph, union ccb *start_ccb); static void proberequestdefaultnegotiation(struct cam_periph *periph); static int proberequestbackoff(struct cam_periph *periph, @@ -708,21 +707,6 @@ probeschedule(struct cam_periph *periph) xpt_schedule(periph, CAM_PRIORITY_XPT); } -static int -device_has_vpd(struct cam_ed *device, uint8_t page_id) -{ - int i, num_pages; - struct scsi_vpd_supported_pages *vpds; - - vpds = (struct scsi_vpd_supported_pages *)device->supported_vpds; - num_pages = device->supported_vpds_len - SVPD_SUPPORTED_PAGES_HDR_LEN; - for (i = 0;i < num_pages;i++) - if (vpds->page_list[i] == page_id) - return 1; - - return 0; -} - static void probestart(struct cam_periph *periph, union ccb *start_ccb) { @@ -910,11 +894,9 @@ again: case PROBE_DEVICE_ID: { struct scsi_vpd_device_id *devid; - struct cam_ed *device; devid = NULL; - device = periph->path->device; - if (device_has_vpd(device, SVPD_DEVICE_ID)) + if (scsi_vpd_supported_page(periph, SVPD_DEVICE_ID)) devid = malloc(SVPD_DEVICE_ID_MAX_SIZE, M_CAMXPT, M_NOWAIT | M_ZERO); @@ -952,7 +934,7 @@ again: device->serial_num_len = 0; } - if (device_has_vpd(device, SVPD_UNIT_SERIAL_NUMBER)) + if (scsi_vpd_supported_page(periph, SVPD_UNIT_SERIAL_NUMBER)) serial_buf = (struct scsi_vpd_unit_serial_number *) malloc(sizeof(*serial_buf), M_CAMXPT, M_NOWAIT|M_ZERO);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306032206.r53M69tT099467>