[PATCH 35/35] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX. Signed-off-by: Kumar Gaurav --- drivers/staging/dgap/dgap_tty.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 2a7a372..0ca72a2 100755 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -52,7 +52,7 @@ #include/* For copy_from_user/copy_to_user */ #include /* For read[bwl]/write[bwl] */ #include - +#include #include "dgap_driver.h" #include "dgap_tty.h" #include "dgap_types.h" @@ -61,18 +61,12 @@ #include "dgap_conf.h" #include "dgap_sysfs.h" -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ -struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) -#endif - /* * internal variables */ static struct board_t *dgap_BoardsByMajor[256]; static uchar *dgap_TmpWriteBuf = NULL; -static DECLARE_MUTEX(dgap_TmpWriteSem); +static DEFINE_MUTEX(dgap_TmpWriteSem); /* * Default transparent print information. @@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int * the board. */ /* we're allowed to block if it's from_user */ - if (down_interruptible(&dgap_TmpWriteSem)) { + if (mutex_lock_interruptible(&dgap_TmpWriteSem)) return (-EINTR); - } if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) { - up(&dgap_TmpWriteSem); + mutex_unlock(&dgap_TmpWriteSem); printk("Write: Copy from user failed!\n"); return -EFAULT; } @@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int if (from_user) { DGAP_UNLOCK(ch->ch_lock, lock_flags); - up(&dgap_TmpWriteSem); + mutex_unlock(&dgap_TmpWriteSem); } else { DGAP_UNLOCK(ch->ch_lock, lock_flags); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 35/35] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
Hi All, Please ignore this patch. I'm sending with correct Subject Line On Thursday 17 April 2014 09:21 PM, Kumar Gaurav wrote: dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX. Signed-off-by: Kumar Gaurav --- drivers/staging/dgap/dgap_tty.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 2a7a372..0ca72a2 100755 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -52,7 +52,7 @@ #include /* For copy_from_user/copy_to_user */ #include /* For read[bwl]/write[bwl] */ #include - +#include #include "dgap_driver.h" #include "dgap_tty.h" #include "dgap_types.h" @@ -61,18 +61,12 @@ #include "dgap_conf.h" #include "dgap_sysfs.h" -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ -struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) -#endif - /* * internal variables */ static struct board_t *dgap_BoardsByMajor[256]; static uchar *dgap_TmpWriteBuf = NULL; -static DECLARE_MUTEX(dgap_TmpWriteSem); +static DEFINE_MUTEX(dgap_TmpWriteSem); /* * Default transparent print information. @@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int * the board. */ /* we're allowed to block if it's from_user */ - if (down_interruptible(&dgap_TmpWriteSem)) { + if (mutex_lock_interruptible(&dgap_TmpWriteSem)) return (-EINTR); - } if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) { - up(&dgap_TmpWriteSem); + mutex_unlock(&dgap_TmpWriteSem); printk("Write: Copy from user failed!\n"); return -EFAULT; } @@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int if (from_user) { DGAP_UNLOCK(ch->ch_lock, lock_flags); - up(&dgap_TmpWriteSem); + mutex_unlock(&dgap_TmpWriteSem); } else { DGAP_UNLOCK(ch->ch_lock, lock_flags); ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX. Signed-off-by: Kumar Gaurav --- drivers/staging/dgap/dgap_tty.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 2a7a372..0ca72a2 100755 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -52,7 +52,7 @@ #include/* For copy_from_user/copy_to_user */ #include /* For read[bwl]/write[bwl] */ #include - +#include #include "dgap_driver.h" #include "dgap_tty.h" #include "dgap_types.h" @@ -61,18 +61,12 @@ #include "dgap_conf.h" #include "dgap_sysfs.h" -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ -struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) -#endif - /* * internal variables */ static struct board_t *dgap_BoardsByMajor[256]; static uchar *dgap_TmpWriteBuf = NULL; -static DECLARE_MUTEX(dgap_TmpWriteSem); +static DEFINE_MUTEX(dgap_TmpWriteSem); /* * Default transparent print information. @@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int * the board. */ /* we're allowed to block if it's from_user */ - if (down_interruptible(&dgap_TmpWriteSem)) { + if (mutex_lock_interruptible(&dgap_TmpWriteSem)) return (-EINTR); - } if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) { - up(&dgap_TmpWriteSem); + mutex_unlock(&dgap_TmpWriteSem); printk("Write: Copy from user failed!\n"); return -EFAULT; } @@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int if (from_user) { DGAP_UNLOCK(ch->ch_lock, lock_flags); - up(&dgap_TmpWriteSem); + mutex_unlock(&dgap_TmpWriteSem); } else { DGAP_UNLOCK(ch->ch_lock, lock_flags); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] Staging:dgap:dgap_tty.c: Upgraded driver to use Mutex instead of semaphore
Hi All, Any update on below patch. Do i need to make any modification? On Thursday 17 April 2014 09:25 PM, Kumar Gaurav wrote: dgap driver uses semaphore for obtaining lock. I upgraded it to use MUTEX. Signed-off-by: Kumar Gaurav --- drivers/staging/dgap/dgap_tty.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 2a7a372..0ca72a2 100755 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -52,7 +52,7 @@ #include /* For copy_from_user/copy_to_user */ #include /* For read[bwl]/write[bwl] */ #include - +#include #include "dgap_driver.h" #include "dgap_tty.h" #include "dgap_types.h" @@ -61,18 +61,12 @@ #include "dgap_conf.h" #include "dgap_sysfs.h" -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ -struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) -#endif - /* * internal variables */ static struct board_t *dgap_BoardsByMajor[256]; static uchar *dgap_TmpWriteBuf = NULL; -static DECLARE_MUTEX(dgap_TmpWriteSem); +static DEFINE_MUTEX(dgap_TmpWriteSem); /* * Default transparent print information. @@ -2004,12 +1998,11 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int * the board. */ /* we're allowed to block if it's from_user */ - if (down_interruptible(&dgap_TmpWriteSem)) { + if (mutex_lock_interruptible(&dgap_TmpWriteSem)) return (-EINTR); - } if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) { - up(&dgap_TmpWriteSem); + mutex_unlock(&dgap_TmpWriteSem); printk("Write: Copy from user failed!\n"); return -EFAULT; } @@ -2093,7 +2086,7 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int if (from_user) { DGAP_UNLOCK(ch->ch_lock, lock_flags); - up(&dgap_TmpWriteSem); + mutex_unlock(&dgap_TmpWriteSem); } else { DGAP_UNLOCK(ch->ch_lock, lock_flags); ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] USBIP:stub_dev.c fixing string splitted into multiple line issue
Fixed String splitted into multiple line issue using macro Signed-off-by: Kumar Gaurav --- drivers/staging/usbip/stub_dev.c | 17 ++--- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 83d629a..3b881e1 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -30,6 +30,8 @@ * In most cases, wildcard matching will be okay because driver binding can be * changed dynamically by a userland program. */ +#define USBIP_REG_INTF "register new interface (bus %u dev %u ifn %u)\n" +#define USBIP_REG_DEV "register new device (bus %u dev %u ifn %u)\n" static struct usb_device_id stub_table[] = { #if 0 /* just an example */ @@ -357,8 +359,9 @@ static int stub_probe(struct usb_interface *interface, busid_priv = get_busid_priv(udev_busid); if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) || (busid_priv->status == STUB_BUSID_OTHER)) { - dev_info(&interface->dev, "%s is not in match_busid table... " -"skip!\n", udev_busid); + dev_info(&interface->dev, +"%s is not in match_busid table... skip!\n", + udev_busid); /* * Return value should be ENODEV or ENOXIO to continue trying @@ -386,8 +389,7 @@ static int stub_probe(struct usb_interface *interface, return -ENODEV; busid_priv->interf_count++; - dev_info(&interface->dev, "usbip-host: register new interface " -"(bus %u dev %u ifn %u)\n", + dev_info(&interface->dev, USBIP_REG_INTF, udev->bus->busnum, udev->devnum, interface->cur_altsetting->desc.bInterfaceNumber); @@ -412,8 +414,8 @@ static int stub_probe(struct usb_interface *interface, if (!sdev) return -ENOMEM; - dev_info(&interface->dev, "usbip-host: register new device " -"(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum, + dev_info(&interface->dev, USBIP_REG_DEV, +udev->bus->busnum, udev->devnum, interface->cur_altsetting->desc.bInterfaceNumber); busid_priv->interf_count = 0; @@ -426,7 +428,8 @@ static int stub_probe(struct usb_interface *interface, err = stub_add_files(&interface->dev); if (err) { - dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid); + dev_err(&interface->dev, "stub_add_files for %s\n", + udev_busid); usb_set_intfdata(interface, NULL); usb_put_intf(interface); usb_put_dev(udev); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] USBIP:stub_dev.c fixing string splitted into multiple line issue
On Thursday 01 August 2013 10:27 AM, Jiany Wu wrote: I have the same idea with julia. It is more difficult to check the log if we use MACRO instead of the strings. If we search in the system log, according to the string, we will find out the macro first. later we also need to find out where the macro is using. 2013/8/1 Julia Lawall mailto:julia.law...@lip6.fr>> On Wed, 31 Jul 2013, Kumar Gaurav wrote: > Fixed String splitted into multiple line issue using macro I'm not an expert on this kind of style issue, but I prefer strings that look like strings. julia > Signed-off-by: Kumar Gaurav mailto:kumargauravgup...@gmail.com>> > --- > drivers/staging/usbip/stub_dev.c | 17 ++--- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c > index 83d629a..3b881e1 100644 > --- a/drivers/staging/usbip/stub_dev.c > +++ b/drivers/staging/usbip/stub_dev.c > @@ -30,6 +30,8 @@ > * In most cases, wildcard matching will be okay because driver binding can be > * changed dynamically by a userland program. > */ > +#define USBIP_REG_INTF "register new interface (bus %u dev %u ifn %u)\n" > +#define USBIP_REG_DEV "register new device (bus %u dev %u ifn %u)\n" > static struct usb_device_id stub_table[] = { > #if 0 > /* just an example */ > @@ -357,8 +359,9 @@ static int stub_probe(struct usb_interface *interface, > busid_priv = get_busid_priv(udev_busid); > if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) || > (busid_priv->status == STUB_BUSID_OTHER)) { > - dev_info(&interface->dev, "%s is not in match_busid table... " > - "skip!\n", udev_busid); > + dev_info(&interface->dev, > + "%s is not in match_busid table... skip!\n", > + udev_busid); > > /* >* Return value should be ENODEV or ENOXIO to continue trying > @@ -386,8 +389,7 @@ static int stub_probe(struct usb_interface *interface, > return -ENODEV; > > busid_priv->interf_count++; > - dev_info(&interface->dev, "usbip-host: register new interface " > - "(bus %u dev %u ifn %u)\n", > + dev_info(&interface->dev, USBIP_REG_INTF, >udev->bus->busnum, udev->devnum, > interface->cur_altsetting->desc.bInterfaceNumber); > > @@ -412,8 +414,8 @@ static int stub_probe(struct usb_interface *interface, > if (!sdev) > return -ENOMEM; > > - dev_info(&interface->dev, "usbip-host: register new device " > - "(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum, > + dev_info(&interface->dev, USBIP_REG_DEV, > + udev->bus->busnum, udev->devnum, > interface->cur_altsetting->desc.bInterfaceNumber); > > busid_priv->interf_count = 0; > @@ -426,7 +428,8 @@ static int stub_probe(struct usb_interface *interface, > > err = stub_add_files(&interface->dev); > if (err) { > - dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid); > + dev_err(&interface->dev, "stub_add_files for %s\n", > + udev_busid); > usb_set_intfdata(interface, NULL); > usb_put_intf(interface); > usb_put_dev(udev); > -- > 1.7.9.5 > > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majord...@vger.kernel.org <mailto:majord...@vger.kernel.org> > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to majord...@vger.kernel.org <mailto:majord...@vger.kernel.org> More majordomo info at http://vger.kernel.org/majordomo-info.html Thanks you all for suggestions. I'll try finding some other way. Regargs Kumar Gaurav ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging:zram:zram_drv.c Fixed Error of trailing whitespace
Fixed by removing trailing whitespace Signed-off-by: Kumar Gaurav --- drivers/staging/zram/zram_drv.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 82c7202..f590715 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -169,7 +169,7 @@ static inline int is_partial_io(struct bio_vec *bvec) static inline int valid_io_request(struct zram *zram, struct bio *bio) { u64 start, end, bound; - + /* unaligned request */ if (unlikely(bio->bi_sector & (ZRAM_SECTOR_PER_LOGICAL_BLOCK - 1))) return 0; -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel