Hello, Danilo,

On April 24, 2025, 8:17 p.m. UTC  Danilo Krummrich wrote:
> On Thu, Apr 24, 2025 at 03:54:48PM -0400, Joel Fernandes wrote:
> > On Wed, Apr 23, 2025 at 05:02:58PM +0200, Danilo Krummrich wrote:
> > > On Wed, Apr 23, 2025 at 10:52:42AM -0400, Joel Fernandes wrote:
> > > > Hello, Danilo,
> > > > Thanks for all the feedback. Due to the volume of feedback, I will 
> > > > respond
> > > > incrementally in multiple emails so we can discuss as we go - hope 
> > > > that's Ok but
> > > > let me know if that is annoying.
> > > 
> > > That's perfectly fine, whatever works best for you. :)
> > > 
> > > > On 4/23/2025 10:06 AM, Danilo Krummrich wrote:
> > > > 
> > > > >> +impl Vbios {
> > > > >> +    /// Read bytes from the ROM at the current end of the data 
> > > > >> vector
> > > > >> +    fn read_more(bar0: &Devres<Bar0>, data: &mut KVec<u8>, len: 
> > > > >> usize) -> Result {
> > > > >> +        let current_len = data.len();
> > > > >> +        let start = ROM_OFFSET + current_len;
> > > > >> +
> > > > >> +        // Ensure length is a multiple of 4 for 32-bit reads
> > > > >> +        if len % core::mem::size_of::<u32>() != 0 {
> > > > >> +            pr_err!("VBIOS read length {} is not a multiple of 
> > > > >> 4\n", len);
> > > > > 
> > > > > Please don't use any of the pr_*() print macros within a driver, use 
> > > > > the dev_*()
> > > > > ones instead.
> > > > 
> > > > Ok I'll switch to this. One slight complication is I've to retrieve the 
> > > > 'dev'
> > > > from the Bar0 and pass that along, but that should be doable.
> > > 
> > > You can also pass the pci::Device reference to VBios::probe() directly.
> > 
> > 
> > This turns out to be rather difficult to do in the whole vbios.rs because
> > we'd have to them propogate pdev to various class methods which may print
> > errors
> 
> Note that you can always create an ARef<pci::Device> instance from a
> &pci::Device, which you can store temporarily if needed. Though I don't think
> it's needed here.
> 
> > (some of which don't make sense to pass pdev to, like try_from()).
> 
> Yeah, it's indeed difficult with a TryFrom or From impl. I guess you're
> referring to things like
> 
>       impl TryFrom<&[u8]> for PcirStruct
> 
> and I actually think that's a bit of an abuse of the TryFrom trait. A &[u8]
> isn't really something that is "natural" to convert to a PcirStruct.
> 
> Instead you should just move this code into a normal constructor, i.e.
> PcirStruct::new(). Here you can then also pass a device reference to print
> errors.

Ok, I had a similar feeling about excessive TryFrom. I will
make this change.

> 
> We should really stick to dev_*() print macros from within driver code.
>   

Ack.

Thanks.

Reply via email to