how to get 'device struct' from 'dev_t' in linux kernel programming?
kernel, linux, usb
Solution
As hiteshradia said `dev_t` is a device number (a major number and minor number). You can however use this along with the knowledge that it is for a block device to get access to the `struct device` associated with it. To do so, use `struct block_device *bdget(dev_t)` from `linux/fs.h`. From this you can use `block_device->bd_part` to get a `struct hd_struct *` for the device and finally use `struct device *part_to_dev(struct hd_struct *)` defined as a macro in `linux/genhd.h`.
Problem
I am quite new to kernel programming and I am following the tutorial given at : USB boot authentication I want to get a 'device struct' of a USB drive. I have 'dev_t' instance of the USB device. Further, I want to check whether the device struct is a USB device or not. I am not able to figure out how to start... Thanks