Re: [PATCH v4] staging: usbip: replace pr_warning() with dev_warn().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 24, 2013, Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> said:

> On Thu, Jun 27, 2013 at 03:34:52PM +0530, navin patidar wrote:
>> dev_warn() is preferred over pr_warning().
>>
>> container_of() is used to get usb_driver pointer from usbip_device container
>> (stub_device or vhci_device), to get device structure required for dev_warn().
>>
>> Signed-off-by: navin patidar <navinp@xxxxxxx>
>> ---
>>  drivers/staging/usbip/usbip_event.c |   11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c
>> index 82123be..1f3a571 100644
>> --- a/drivers/staging/usbip/usbip_event.c
>> +++ b/drivers/staging/usbip/usbip_event.c
>> @@ -21,6 +21,8 @@
>>  #include <linux/export.h>
>>
>>  #include "usbip_common.h"
>> +#include "stub.h"
>> +#include "vhci.h"
>>
>>  static int event_handler(struct usbip_device *ud)
>>  {
>> @@ -85,7 +87,14 @@ int usbip_start_eh(struct usbip_device *ud)
>>
>>      ud->eh = kthread_run(event_handler_loop, ud, "usbip_eh");
>>      if (IS_ERR(ud->eh)) {
>> -        pr_warning("Unable to start control thread\n");
>> +        struct device *dev;
>> +
>> +        if (ud->side == USBIP_STUB)
>> +            dev = &container_of(ud, struct stub_device, ud)->udev->dev;
>> +        else
>> +            dev = &container_of(ud, struct vhci_device, ud)->udev->dev;
>
> Putting '&' in front of container_of seems odd, are you sure it's needed
> here?  If ud is a pointer, everything else should "just work" properly
> without that.

Removing '&'   caused following error.
drivers/staging/usbip/usbip_event.c: In function ‘usbip_start_eh’:
drivers/staging/usbip/usbip_event.c:93:8: error: incompatible types
when assigning to type ‘struct device *’ from type ‘struct device’
drivers/staging/usbip/usbip_event.c:95:8: error: incompatible types
when assigning to type ‘struct device *’ from type ‘struct device’

dev needs to be initialized with address of dev (struct device ) which
is member of struct usb_device pointed by the udev.

To make it more clear i can change it to

dev = &(container_of(ud, struct vhci_device, ud)->udev->dev);

 or

struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
dev = &(vdev->udev->dev);

regards,
--navin-patidar
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel





[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux