Jiri Slaby wrote: >On 10/10/05, Manu Abraham wrote: > > >>Jiri Slaby wrote: >>The dprintk() macro (in mantis_common.h ) was looking very badly with >>wrap, which Andrew also commented on (about the col's) (the macro being >>the same, eventhough i was using it elsewhere) it being more than 80 >>cols, but wrapping the macro made it look like hell. >> >> >Did you consider using of (inline) function. It would be better in this case. >[Consider using __attribute__ ((format(...)))] > > > Ok, that sounds better .. I will take a look at how it looks .. >>>>>> mantis->pdev = pdev; >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>If you work with this out from pci functions, you should call >>>>>pci_get_dev and in exit function pci_dev_put, otherwise you don't need >>>>>it at all. >>>>> >>>>> >>>>> >>>>> >>>>Well i am using it in mantis_dma.c, pci_alloc/free >>>> >>>> >>>> >>>> >>>And it is called only from places, where pdev is known (i.e. in >>>parameter of function, e.g. mantis_pci_probe). So you don't need it to >>>store in mantis, but only call mantis_dma_init(mantis, pdev). Read >>>below. >>> >>> >>> >>> >>>>You mean rather than saving off the pointer, i do a pci_get_dev() >>>>and later on in the exit routine, i do a pci_dev_put() .. ? >>>> >>>> >>>> >>>> >>>But if you really want it, call pci_get_dev() and store it into mantis >>>struct. In the _device_ exit routine call the latter. But I think, >>>that not to store is better, or the best is to call >>>mantis_dma_init(pdev) and do pci_get_drvdata inside. >>> >>> >>> >>> >>i think will pass (pdev) it as a function argument. Looks a bit more cleaner >>But what i fail to understand is , if you can pass it as an argument, >>why can't you save the pointer in the struct ? >> >> >You can do that. I don't know, how do you handle the mantis structure. >But if you need pdev in it, you should do (in most cases) pci_dev_get >to increase ref count = you use it in one more place and telling >kernel by that: do not free it, because I need it, until I call >pci_dev_put. > > > I would need to do that even if i pass it as an argument to the function , right ? what i mean is if i do a dma_init(pdev) and in int dma_init(struct pci_dev *pdev) { struct x *a = pci_get_drvdata(pdev); pci_alloc_consistent(pdev, .. ); } alone would be sufficient ? I went this way as you can see .. Regards, Manu