Fri Jul 10 09:49:56 2015 UTC ()
mark all the device entry points static.


(mrg)
diff -r1.323 -r1.324 src/sys/dev/raidframe/rf_netbsdkintf.c

cvs diff -r1.323 -r1.324 src/sys/dev/raidframe/rf_netbsdkintf.c (expand / switch to unified diff)

--- src/sys/dev/raidframe/rf_netbsdkintf.c 2015/04/26 15:15:20 1.323
+++ src/sys/dev/raidframe/rf_netbsdkintf.c 2015/07/10 09:49:56 1.324
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rf_netbsdkintf.c,v 1.323 2015/04/26 15:15:20 mlelstv Exp $ */ 1/* $NetBSD: rf_netbsdkintf.c,v 1.324 2015/07/10 09:49:56 mrg Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Greg Oster; Jason R. Thorpe. 8 * by Greg Oster; Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -91,27 +91,27 @@ @@ -91,27 +91,27 @@
91 * Pittsburgh PA 15213-3890 91 * Pittsburgh PA 15213-3890
92 * 92 *
93 * any improvements or extensions that they make and grant Carnegie the 93 * any improvements or extensions that they make and grant Carnegie the
94 * rights to redistribute these changes. 94 * rights to redistribute these changes.
95 */ 95 */
96 96
97/*********************************************************** 97/***********************************************************
98 * 98 *
99 * rf_kintf.c -- the kernel interface routines for RAIDframe 99 * rf_kintf.c -- the kernel interface routines for RAIDframe
100 * 100 *
101 ***********************************************************/ 101 ***********************************************************/
102 102
103#include <sys/cdefs.h> 103#include <sys/cdefs.h>
104__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.323 2015/04/26 15:15:20 mlelstv Exp $"); 104__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.324 2015/07/10 09:49:56 mrg Exp $");
105 105
106#ifdef _KERNEL_OPT 106#ifdef _KERNEL_OPT
107#include "opt_compat_netbsd.h" 107#include "opt_compat_netbsd.h"
108#include "opt_raid_autoconfig.h" 108#include "opt_raid_autoconfig.h"
109#endif 109#endif
110 110
111#include <sys/param.h> 111#include <sys/param.h>
112#include <sys/errno.h> 112#include <sys/errno.h>
113#include <sys/pool.h> 113#include <sys/pool.h>
114#include <sys/proc.h> 114#include <sys/proc.h>
115#include <sys/queue.h> 115#include <sys/queue.h>
116#include <sys/disk.h> 116#include <sys/disk.h>
117#include <sys/device.h> 117#include <sys/device.h>
@@ -185,34 +185,34 @@ static void raid_attach(device_t, device @@ -185,34 +185,34 @@ static void raid_attach(device_t, device
185static int raid_detach(device_t, int); 185static int raid_detach(device_t, int);
186 186
187static int raidread_component_area(dev_t, struct vnode *, void *, size_t,  187static int raidread_component_area(dev_t, struct vnode *, void *, size_t,
188 daddr_t, daddr_t); 188 daddr_t, daddr_t);
189static int raidwrite_component_area(dev_t, struct vnode *, void *, size_t, 189static int raidwrite_component_area(dev_t, struct vnode *, void *, size_t,
190 daddr_t, daddr_t, int); 190 daddr_t, daddr_t, int);
191 191
192static int raidwrite_component_label(unsigned, 192static int raidwrite_component_label(unsigned,
193 dev_t, struct vnode *, RF_ComponentLabel_t *); 193 dev_t, struct vnode *, RF_ComponentLabel_t *);
194static int raidread_component_label(unsigned, 194static int raidread_component_label(unsigned,
195 dev_t, struct vnode *, RF_ComponentLabel_t *); 195 dev_t, struct vnode *, RF_ComponentLabel_t *);
196 196
197 197
198dev_type_open(raidopen); 198static dev_type_open(raidopen);
199dev_type_close(raidclose); 199static dev_type_close(raidclose);
200dev_type_read(raidread); 200static dev_type_read(raidread);
201dev_type_write(raidwrite); 201static dev_type_write(raidwrite);
202dev_type_ioctl(raidioctl); 202static dev_type_ioctl(raidioctl);
203dev_type_strategy(raidstrategy); 203static dev_type_strategy(raidstrategy);
204dev_type_dump(raiddump); 204static dev_type_dump(raiddump);
205dev_type_size(raidsize); 205static dev_type_size(raidsize);
206 206
207const struct bdevsw raid_bdevsw = { 207const struct bdevsw raid_bdevsw = {
208 .d_open = raidopen, 208 .d_open = raidopen,
209 .d_close = raidclose, 209 .d_close = raidclose,
210 .d_strategy = raidstrategy, 210 .d_strategy = raidstrategy,
211 .d_ioctl = raidioctl, 211 .d_ioctl = raidioctl,
212 .d_dump = raiddump, 212 .d_dump = raiddump,
213 .d_psize = raidsize, 213 .d_psize = raidsize,
214 .d_discard = nodiscard, 214 .d_discard = nodiscard,
215 .d_flag = D_DISK 215 .d_flag = D_DISK
216}; 216};
217 217
218const struct cdevsw raid_cdevsw = { 218const struct cdevsw raid_cdevsw = {
@@ -587,28 +587,27 @@ rf_buildroothack(RF_ConfigSet_t *config_ @@ -587,28 +587,27 @@ rf_buildroothack(RF_ConfigSet_t *config_
587 } 587 }
588 mutex_exit(&raid_lock); 588 mutex_exit(&raid_lock);
589 589
590 if (num_root == 1) { 590 if (num_root == 1) {
591 booted_device = rsc->sc_dev; 591 booted_device = rsc->sc_dev;
592 booted_partition = 0; /* XXX assume 'a' */ 592 booted_partition = 0; /* XXX assume 'a' */
593 } else { 593 } else {
594 /* we can't guess.. require the user to answer... */ 594 /* we can't guess.. require the user to answer... */
595 boothowto |= RB_ASKNAME; 595 boothowto |= RB_ASKNAME;
596 } 596 }
597 } 597 }
598} 598}
599 599
600 600static int
601int 
602raidsize(dev_t dev) 601raidsize(dev_t dev)
603{ 602{
604 struct raid_softc *rs; 603 struct raid_softc *rs;
605 struct disklabel *lp; 604 struct disklabel *lp;
606 int part, unit, omask, size; 605 int part, unit, omask, size;
607 606
608 unit = raidunit(dev); 607 unit = raidunit(dev);
609 if ((rs = raidget(unit)) == NULL) 608 if ((rs = raidget(unit)) == NULL)
610 return -1; 609 return -1;
611 if ((rs->sc_flags & RAIDF_INITED) == 0) 610 if ((rs->sc_flags & RAIDF_INITED) == 0)
612 return (-1); 611 return (-1);
613 612
614 part = DISKPART(dev); 613 part = DISKPART(dev);
@@ -621,27 +620,27 @@ raidsize(dev_t dev) @@ -621,27 +620,27 @@ raidsize(dev_t dev)
621 if (lp->d_partitions[part].p_fstype != FS_SWAP) 620 if (lp->d_partitions[part].p_fstype != FS_SWAP)
622 size = -1; 621 size = -1;
623 else 622 else
624 size = lp->d_partitions[part].p_size * 623 size = lp->d_partitions[part].p_size *
625 (lp->d_secsize / DEV_BSIZE); 624 (lp->d_secsize / DEV_BSIZE);
626 625
627 if (omask == 0 && raidclose(dev, 0, S_IFBLK, curlwp)) 626 if (omask == 0 && raidclose(dev, 0, S_IFBLK, curlwp))
628 return (-1); 627 return (-1);
629 628
630 return (size); 629 return (size);
631 630
632} 631}
633 632
634int 633static int
635raiddump(dev_t dev, daddr_t blkno, void *va, size_t size) 634raiddump(dev_t dev, daddr_t blkno, void *va, size_t size)
636{ 635{
637 int unit = raidunit(dev); 636 int unit = raidunit(dev);
638 struct raid_softc *rs; 637 struct raid_softc *rs;
639 const struct bdevsw *bdev; 638 const struct bdevsw *bdev;
640 struct disklabel *lp; 639 struct disklabel *lp;
641 RF_Raid_t *raidPtr; 640 RF_Raid_t *raidPtr;
642 daddr_t offset; 641 daddr_t offset;
643 int part, c, sparecol, j, scol, dumpto; 642 int part, c, sparecol, j, scol, dumpto;
644 int error = 0; 643 int error = 0;
645 644
646 if ((rs = raidget(unit)) == NULL) 645 if ((rs = raidget(unit)) == NULL)
647 return ENXIO; 646 return ENXIO;
@@ -757,28 +756,29 @@ raiddump(dev_t dev, daddr_t blkno, void  @@ -757,28 +756,29 @@ raiddump(dev_t dev, daddr_t blkno, void
757 set, and also adding RF_PROTECTED_SECTORS, we get a 756 set, and also adding RF_PROTECTED_SECTORS, we get a
758 value that is relative to the partition used for the 757 value that is relative to the partition used for the
759 underlying component. 758 underlying component.
760 */ 759 */
761  760
762 error = (*bdev->d_dump)(raidPtr->Disks[dumpto].dev,  761 error = (*bdev->d_dump)(raidPtr->Disks[dumpto].dev,
763 blkno + offset, va, size); 762 blkno + offset, va, size);
764  763
765out: 764out:
766 raidunlock(rs); 765 raidunlock(rs);
767  766
768 return error; 767 return error;
769} 768}
 769
770/* ARGSUSED */ 770/* ARGSUSED */
771int 771static int
772raidopen(dev_t dev, int flags, int fmt, 772raidopen(dev_t dev, int flags, int fmt,
773 struct lwp *l) 773 struct lwp *l)
774{ 774{
775 int unit = raidunit(dev); 775 int unit = raidunit(dev);
776 struct raid_softc *rs; 776 struct raid_softc *rs;
777 struct disklabel *lp; 777 struct disklabel *lp;
778 int part, pmask; 778 int part, pmask;
779 int error = 0; 779 int error = 0;
780 780
781 if ((rs = raidget(unit)) == NULL) 781 if ((rs = raidget(unit)) == NULL)
782 return ENXIO; 782 return ENXIO;
783 if ((error = raidlock(rs)) != 0) 783 if ((error = raidlock(rs)) != 0)
784 return (error); 784 return (error);
@@ -842,28 +842,29 @@ raidopen(dev_t dev, int flags, int fmt, @@ -842,28 +842,29 @@ raidopen(dev_t dev, int flags, int fmt,
842 } 842 }
843 843
844 844
845 rs->sc_dkdev.dk_openmask = 845 rs->sc_dkdev.dk_openmask =
846 rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask; 846 rs->sc_dkdev.dk_copenmask | rs->sc_dkdev.dk_bopenmask;
847 847
848bad: 848bad:
849 raidunlock(rs); 849 raidunlock(rs);
850 850
851 return (error); 851 return (error);
852 852
853 853
854} 854}
 855
855/* ARGSUSED */ 856/* ARGSUSED */
856int 857static int
857raidclose(dev_t dev, int flags, int fmt, struct lwp *l) 858raidclose(dev_t dev, int flags, int fmt, struct lwp *l)
858{ 859{
859 int unit = raidunit(dev); 860 int unit = raidunit(dev);
860 struct raid_softc *rs; 861 struct raid_softc *rs;
861 int error = 0; 862 int error = 0;
862 int part; 863 int part;
863 864
864 if ((rs = raidget(unit)) == NULL) 865 if ((rs = raidget(unit)) == NULL)
865 return ENXIO; 866 return ENXIO;
866 867
867 if ((error = raidlock(rs)) != 0) 868 if ((error = raidlock(rs)) != 0)
868 return (error); 869 return (error);
869 870
@@ -892,27 +893,27 @@ raidclose(dev_t dev, int flags, int fmt, @@ -892,27 +893,27 @@ raidclose(dev_t dev, int flags, int fmt,
892 rf_update_component_labels(&rs->sc_r, 893 rf_update_component_labels(&rs->sc_r,
893 RF_FINAL_COMPONENT_UPDATE); 894 RF_FINAL_COMPONENT_UPDATE);
894 895
895 /* If the kernel is shutting down, it will detach 896 /* If the kernel is shutting down, it will detach
896 * this RAID set soon enough. 897 * this RAID set soon enough.
897 */ 898 */
898 } 899 }
899 900
900 raidunlock(rs); 901 raidunlock(rs);
901 return (0); 902 return (0);
902 903
903} 904}
904 905
905void 906static void
906raidstrategy(struct buf *bp) 907raidstrategy(struct buf *bp)
907{ 908{
908 unsigned int unit = raidunit(bp->b_dev); 909 unsigned int unit = raidunit(bp->b_dev);
909 RF_Raid_t *raidPtr; 910 RF_Raid_t *raidPtr;
910 int wlabel; 911 int wlabel;
911 struct raid_softc *rs; 912 struct raid_softc *rs;
912 913
913 if ((rs = raidget(unit)) == NULL) { 914 if ((rs = raidget(unit)) == NULL) {
914 bp->b_error = ENXIO; 915 bp->b_error = ENXIO;
915 goto done; 916 goto done;
916 } 917 }
917 if ((rs->sc_flags & RAIDF_INITED) == 0) { 918 if ((rs->sc_flags & RAIDF_INITED) == 0) {
918 bp->b_error = ENXIO; 919 bp->b_error = ENXIO;
@@ -962,44 +963,46 @@ raidstrategy(struct buf *bp) @@ -962,44 +963,46 @@ raidstrategy(struct buf *bp)
962 /* stuff it onto our queue */ 963 /* stuff it onto our queue */
963 bufq_put(rs->buf_queue, bp); 964 bufq_put(rs->buf_queue, bp);
964 965
965 /* scheduled the IO to happen at the next convenient time */ 966 /* scheduled the IO to happen at the next convenient time */
966 rf_signal_cond2(raidPtr->iodone_cv); 967 rf_signal_cond2(raidPtr->iodone_cv);
967 rf_unlock_mutex2(raidPtr->iodone_lock); 968 rf_unlock_mutex2(raidPtr->iodone_lock);
968 969
969 return; 970 return;
970 971
971done: 972done:
972 bp->b_resid = bp->b_bcount; 973 bp->b_resid = bp->b_bcount;
973 biodone(bp); 974 biodone(bp);
974} 975}
 976
975/* ARGSUSED */ 977/* ARGSUSED */
976int 978static int
977raidread(dev_t dev, struct uio *uio, int flags) 979raidread(dev_t dev, struct uio *uio, int flags)
978{ 980{
979 int unit = raidunit(dev); 981 int unit = raidunit(dev);
980 struct raid_softc *rs; 982 struct raid_softc *rs;
981 983
982 if ((rs = raidget(unit)) == NULL) 984 if ((rs = raidget(unit)) == NULL)
983 return ENXIO; 985 return ENXIO;
984 986
985 if ((rs->sc_flags & RAIDF_INITED) == 0) 987 if ((rs->sc_flags & RAIDF_INITED) == 0)
986 return (ENXIO); 988 return (ENXIO);
987 989
988 return (physio(raidstrategy, NULL, dev, B_READ, minphys, uio)); 990 return (physio(raidstrategy, NULL, dev, B_READ, minphys, uio));
989 991
990} 992}
 993
991/* ARGSUSED */ 994/* ARGSUSED */
992int 995static int
993raidwrite(dev_t dev, struct uio *uio, int flags) 996raidwrite(dev_t dev, struct uio *uio, int flags)
994{ 997{
995 int unit = raidunit(dev); 998 int unit = raidunit(dev);
996 struct raid_softc *rs; 999 struct raid_softc *rs;
997 1000
998 if ((rs = raidget(unit)) == NULL) 1001 if ((rs = raidget(unit)) == NULL)
999 return ENXIO; 1002 return ENXIO;
1000 1003
1001 if ((rs->sc_flags & RAIDF_INITED) == 0) 1004 if ((rs->sc_flags & RAIDF_INITED) == 0)
1002 return (ENXIO); 1005 return (ENXIO);
1003 1006
1004 return (physio(raidstrategy, NULL, dev, B_WRITE, minphys, uio)); 1007 return (physio(raidstrategy, NULL, dev, B_WRITE, minphys, uio));
1005 1008
@@ -1027,27 +1030,27 @@ raid_detach_unlocked(struct raid_softc * @@ -1027,27 +1030,27 @@ raid_detach_unlocked(struct raid_softc *
1027 else 1030 else
1028 rs->sc_flags &= ~(RAIDF_INITED|RAIDF_SHUTDOWN); 1031 rs->sc_flags &= ~(RAIDF_INITED|RAIDF_SHUTDOWN);
1029 1032
1030 /* Detach the disk. */ 1033 /* Detach the disk. */
1031 dkwedge_delall(&rs->sc_dkdev); 1034 dkwedge_delall(&rs->sc_dkdev);
1032 disk_detach(&rs->sc_dkdev); 1035 disk_detach(&rs->sc_dkdev);
1033 disk_destroy(&rs->sc_dkdev); 1036 disk_destroy(&rs->sc_dkdev);
1034 1037
1035 aprint_normal_dev(rs->sc_dev, "detached\n"); 1038 aprint_normal_dev(rs->sc_dev, "detached\n");
1036 1039
1037 return 0; 1040 return 0;
1038} 1041}
1039 1042
1040int 1043static int
1041raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) 1044raidioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
1042{ 1045{
1043 int unit = raidunit(dev); 1046 int unit = raidunit(dev);
1044 int error = 0; 1047 int error = 0;
1045 int part, pmask, s; 1048 int part, pmask, s;
1046 cfdata_t cf; 1049 cfdata_t cf;
1047 struct raid_softc *rs; 1050 struct raid_softc *rs;
1048 RF_Config_t *k_cfg, *u_cfg; 1051 RF_Config_t *k_cfg, *u_cfg;
1049 RF_Raid_t *raidPtr; 1052 RF_Raid_t *raidPtr;
1050 RF_RaidDisk_t *diskPtr; 1053 RF_RaidDisk_t *diskPtr;
1051 RF_AccTotals_t *totals; 1054 RF_AccTotals_t *totals;
1052 RF_DeviceConfig_t *d_cfg, **ucfgp; 1055 RF_DeviceConfig_t *d_cfg, **ucfgp;
1053 u_char *specific_buf; 1056 u_char *specific_buf;