aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/cdrom/viocd.c37
1 files changed, 13 insertions, 24 deletions
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index e51550db1575..b88fdebe77f6 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -136,17 +136,12 @@ struct cdrom_info {
136 char type[4]; 136 char type[4];
137 char model[3]; 137 char model[3];
138}; 138};
139/*
140 * This needs to be allocated since it is passed to the
141 * Hypervisor and we may be a module.
142 */
143static struct cdrom_info *viocd_unitinfo;
144static dma_addr_t unitinfo_dmaaddr;
145 139
146struct disk_info { 140struct disk_info {
147 struct gendisk *viocd_disk; 141 struct gendisk *viocd_disk;
148 struct cdrom_device_info viocd_info; 142 struct cdrom_device_info viocd_info;
149 struct device *dev; 143 struct device *dev;
144 struct cdrom_info unitinfo;
150}; 145};
151static struct disk_info viocd_diskinfo[VIOCD_MAX_CD]; 146static struct disk_info viocd_diskinfo[VIOCD_MAX_CD];
152 147
@@ -164,9 +159,9 @@ static int proc_viocd_show(struct seq_file *m, void *v)
164 for (i = 0; i < viocd_numdev; i++) { 159 for (i = 0; i < viocd_numdev; i++) {
165 seq_printf(m, "viocd device %d is iSeries resource %10.10s" 160 seq_printf(m, "viocd device %d is iSeries resource %10.10s"
166 "type %4.4s, model %3.3s\n", 161 "type %4.4s, model %3.3s\n",
167 i, viocd_unitinfo[i].rsrcname, 162 i, viocd_diskinfo[i].unitinfo.rsrcname,
168 viocd_unitinfo[i].type, 163 viocd_diskinfo[i].unitinfo.type,
169 viocd_unitinfo[i].model); 164 viocd_diskinfo[i].unitinfo.model);
170 } 165 }
171 return 0; 166 return 0;
172} 167}
@@ -222,6 +217,8 @@ static void __init get_viocd_info(void)
222 HvLpEvent_Rc hvrc; 217 HvLpEvent_Rc hvrc;
223 int i; 218 int i;
224 struct viocd_waitevent we; 219 struct viocd_waitevent we;
220 struct cdrom_info *viocd_unitinfo;
221 dma_addr_t unitinfo_dmaaddr;
225 222
226 viocd_unitinfo = dma_alloc_coherent(iSeries_vio_dev, 223 viocd_unitinfo = dma_alloc_coherent(iSeries_vio_dev,
227 sizeof(*viocd_unitinfo) * VIOCD_MAX_CD, 224 sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
@@ -259,16 +256,15 @@ static void __init get_viocd_info(void)
259 goto error_ret; 256 goto error_ret;
260 } 257 }
261 258
262 for (i = 0; (i < VIOCD_MAX_CD) && viocd_unitinfo[i].rsrcname[0]; i++) 259 for (i = 0; (i < VIOCD_MAX_CD) && viocd_unitinfo[i].rsrcname[0]; i++) {
260 viocd_diskinfo[viocd_numdev].unitinfo = viocd_unitinfo[i];
263 viocd_numdev++; 261 viocd_numdev++;
262 }
264 263
265error_ret: 264error_ret:
266 if (viocd_numdev == 0) { 265 dma_free_coherent(iSeries_vio_dev,
267 dma_free_coherent(iSeries_vio_dev, 266 sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
268 sizeof(*viocd_unitinfo) * VIOCD_MAX_CD, 267 viocd_unitinfo, unitinfo_dmaaddr);
269 viocd_unitinfo, unitinfo_dmaaddr);
270 viocd_unitinfo = NULL;
271 }
272} 268}
273 269
274static int viocd_open(struct cdrom_device_info *cdi, int purpose) 270static int viocd_open(struct cdrom_device_info *cdi, int purpose)
@@ -674,7 +670,7 @@ static int viocd_probe(struct vio_dev *vdev, const struct vio_device_id *id)
674 670
675 d = &viocd_diskinfo[deviceno]; 671 d = &viocd_diskinfo[deviceno];
676 c = &d->viocd_info; 672 c = &d->viocd_info;
677 ci = &viocd_unitinfo[deviceno]; 673 ci = &d->unitinfo;
678 674
679 c->ops = &viocd_dops; 675 c->ops = &viocd_dops;
680 c->speed = 4; 676 c->speed = 4;
@@ -816,9 +812,6 @@ static int __init viocd_init(void)
816 return 0; 812 return 0;
817 813
818out_free_info: 814out_free_info:
819 dma_free_coherent(iSeries_vio_dev,
820 sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
821 viocd_unitinfo, unitinfo_dmaaddr);
822 vio_clearHandler(viomajorsubtype_cdio); 815 vio_clearHandler(viomajorsubtype_cdio);
823 viopath_close(viopath_hostLp, viomajorsubtype_cdio, MAX_CD_REQ + 2); 816 viopath_close(viopath_hostLp, viomajorsubtype_cdio, MAX_CD_REQ + 2);
824out_unregister: 817out_unregister:
@@ -830,10 +823,6 @@ static void __exit viocd_exit(void)
830{ 823{
831 remove_proc_entry("iSeries/viocd", NULL); 824 remove_proc_entry("iSeries/viocd", NULL);
832 vio_unregister_driver(&viocd_driver); 825 vio_unregister_driver(&viocd_driver);
833 if (viocd_unitinfo != NULL)
834 dma_free_coherent(iSeries_vio_dev,
835 sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
836 viocd_unitinfo, unitinfo_dmaaddr);
837 viopath_close(viopath_hostLp, viomajorsubtype_cdio, MAX_CD_REQ + 2); 826 viopath_close(viopath_hostLp, viomajorsubtype_cdio, MAX_CD_REQ + 2);
838 vio_clearHandler(viomajorsubtype_cdio); 827 vio_clearHandler(viomajorsubtype_cdio);
839 unregister_blkdev(VIOCD_MAJOR, VIOCD_DEVICE); 828 unregister_blkdev(VIOCD_MAJOR, VIOCD_DEVICE);