@@ -110,40 +110,18 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
110
110
goto err0 ;
111
111
}
112
112
113
- /* The sm501 chip is equipped with local memory that may be used
114
- * by on-chip devices such as the video controller and the usb host.
115
- * This driver uses dma_declare_coherent_memory() to make sure
116
- * usb allocations with dma_alloc_coherent() allocate from
117
- * this local memory. The dma_handle returned by dma_alloc_coherent()
118
- * will be an offset starting from 0 for the first local memory byte.
119
- *
120
- * So as long as data is allocated using dma_alloc_coherent() all is
121
- * fine. This is however not always the case - buffers may be allocated
122
- * using kmalloc() - so the usb core needs to be told that it must copy
123
- * data into our local memory if the buffers happen to be placed in
124
- * regular memory. The HCD_LOCAL_MEM flag does just that.
125
- */
126
-
127
- retval = dma_declare_coherent_memory (dev , mem -> start ,
128
- mem -> start - mem -> parent -> start ,
129
- resource_size (mem ));
130
- if (retval ) {
131
- dev_err (dev , "cannot declare coherent memory\n" );
132
- goto err1 ;
133
- }
134
-
135
113
/* allocate, reserve and remap resources for registers */
136
114
res = platform_get_resource (pdev , IORESOURCE_MEM , 0 );
137
115
if (res == NULL ) {
138
116
dev_err (dev , "no resource definition for registers\n" );
139
117
retval = - ENOENT ;
140
- goto err2 ;
118
+ goto err1 ;
141
119
}
142
120
143
121
hcd = usb_create_hcd (driver , & pdev -> dev , dev_name (& pdev -> dev ));
144
122
if (!hcd ) {
145
123
retval = - ENOMEM ;
146
- goto err2 ;
124
+ goto err1 ;
147
125
}
148
126
149
127
hcd -> rsrc_start = res -> start ;
@@ -164,6 +142,24 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
164
142
165
143
ohci_hcd_init (hcd_to_ohci (hcd ));
166
144
145
+ /* The sm501 chip is equipped with local memory that may be used
146
+ * by on-chip devices such as the video controller and the usb host.
147
+ * This driver uses genalloc so that usb allocations with
148
+ * gen_pool_dma_alloc() allocate from this local memory. The dma_handle
149
+ * returned by gen_pool_dma_alloc() will be an offset starting from 0
150
+ * for the first local memory byte.
151
+ *
152
+ * So as long as data is allocated using gen_pool_dma_alloc() all is
153
+ * fine. This is however not always the case - buffers may be allocated
154
+ * using kmalloc() - so the usb core needs to be told that it must copy
155
+ * data into our local memory if the buffers happen to be placed in
156
+ * regular memory. The HCD_LOCAL_MEM flag does just that.
157
+ */
158
+
159
+ if (usb_hcd_setup_local_mem (hcd , mem -> start ,
160
+ mem -> start - mem -> parent -> start ,
161
+ resource_size (mem )) < 0 )
162
+ goto err5 ;
167
163
retval = usb_add_hcd (hcd , irq , IRQF_SHARED );
168
164
if (retval )
169
165
goto err5 ;
@@ -181,8 +177,6 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
181
177
release_mem_region (hcd -> rsrc_start , hcd -> rsrc_len );
182
178
err3 :
183
179
usb_put_hcd (hcd );
184
- err2 :
185
- dma_release_declared_memory (dev );
186
180
err1 :
187
181
release_mem_region (mem -> start , resource_size (mem ));
188
182
err0 :
@@ -197,7 +191,6 @@ static int ohci_hcd_sm501_drv_remove(struct platform_device *pdev)
197
191
usb_remove_hcd (hcd );
198
192
release_mem_region (hcd -> rsrc_start , hcd -> rsrc_len );
199
193
usb_put_hcd (hcd );
200
- dma_release_declared_memory (& pdev -> dev );
201
194
mem = platform_get_resource (pdev , IORESOURCE_MEM , 1 );
202
195
if (mem )
203
196
release_mem_region (mem -> start , resource_size (mem ));
0 commit comments