linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Patch to replace DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE
@ 2018-03-31 13:34 Wasim Nazir
  0 siblings, 0 replies; 4+ messages in thread
From: Wasim Nazir @ 2018-03-31 13:34 UTC (permalink / raw)
  To: jhogan, kys, linuxdrivers, linux-kernel, devel, linux-arm-kernel
  Cc: Wasim Nazir, Ralf Baechle, Ard Biesheuvel, Haiyang Zhang,
	Stephen Hemminger, Benjamin Herrenschmidt, Ariel Elior,
	everest-linux-l2, James E.J. Bottomley, Martin K. Petersen,
	Eric Anholt, Stefan Wahren, Greg Kroah-Hartman, Petr Mladek,
	Sergey Senozhatsky, Steven Rostedt, David Daney, Mihaela Muraru,
	Kishore KP, Sidong Yang, Al Viro, Phil Elwell, Ingo Molnar,
	Tycho Andersen, linux-mips, linux-efi, linuxppc-dev, netdev,
	linux-scsi, linux-rpi-kernel, devel


[-- Attachment #1.1: Type: text/plain, Size: 6882 bytes --]

This patch replaces the macro DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE.
This is necessary because otherwise it makes confusion with counting
semaphore.

To apply the patch, in the root of a kernel tree use:
patch -p1 < 0001-Replace-DEFINE_SEMAPHORE-with-DEFINE_BINARY_SEMAPHOR.patch

Please let me know any feedback you have on this patch.

Thank You,
Wasim Nazir,
Software Engineer,
Pathpartner Tech

Signed-off-by: Wasim Nazir <wasim.nazir@pathpartnertech.com>
---
 arch/mips/cavium-octeon/setup.c
               | 2 +-
 drivers/firmware/efi/runtime-wrappers.c
              | 2 +-
 drivers/firmware/efi/vars.c
                       | 2 +-
 drivers/hv/vmbus_drv.c
                       | 2 +-
 drivers/macintosh/adb.c
                      | 2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
    | 2 +-
 drivers/scsi/esas2r/esas2r_ioctl.c
                   | 2 +-
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c  | 2 +-
 include/linux/semaphore.h
                    | 2 +-
 kernel/printk/printk.c
                            | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/mips/cavium-octeon/setup.c
b/arch/mips/cavium-octeon/setup.c
index a8034d0..983b464 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -68,7 +68,7 @@
 static unsigned long long max_memory = ULLONG_MAX;
 static unsigned long long reserve_low_mem;

-DEFINE_SEMAPHORE(octeon_bootbus_sem);
+DEFINE_BINARY_SEMAPHORE(octeon_bootbus_sem);
 EXPORT_SYMBOL(octeon_bootbus_sem);

 struct octeon_boot_descriptor *octeon_boot_desc_ptr;
diff --git a/drivers/firmware/efi/runtime-wrappers.c
b/drivers/firmware/efi/runtime-wrappers.c
index ae54870b..5706f8c 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -88,7 +88,7 @@ void efi_call_virt_check_flags(unsigned long flags, const
char *call)
  * none of the remaining functions are actually ever called at runtime.
  * So let's just use a single lock to serialize all Runtime Services calls.
  */
-static DEFINE_SEMAPHORE(efi_runtime_lock);
+static DEFINE_BINARY_SEMAPHORE(efi_runtime_lock);

 static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 {
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index 9336ffd..e8aab38 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -43,7 +43,7 @@
  * 2) ->ops calls
  * 3) (un)registration of __efivars
  */
-static DEFINE_SEMAPHORE(efivars_lock);
+static DEFINE_BINARY_SEMAPHORE(efivars_lock);

 static bool efivar_wq_enabled = true;
 DECLARE_WORK(efivar_work, NULL);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index bc65c4d..a75ad8a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -88,7 +88,7 @@ static int hyperv_die_event(struct notifier_block *nb,
unsigned long val,
 static const char *fb_mmio_name = "fb_range";
 static struct resource *fb_mmio;
 static struct resource *hyperv_mmio;
-static DEFINE_SEMAPHORE(hyperv_mmio_lock);
+static DEFINE_BINARY_SEMAPHORE(hyperv_mmio_lock);

 static int vmbus_exists(void)
 {
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 4c8097e..55725e0 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -80,7 +80,7 @@
 BLOCKING_NOTIFIER_HEAD(adb_client_list);
 static int adb_got_sleep;
 static int adb_inited;
-static DEFINE_SEMAPHORE(adb_probe_mutex);
+static DEFINE_BINARY_SEMAPHORE(adb_probe_mutex);
 static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index b8388e9..eac1bf9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -283,7 +283,7 @@ enum bnx2x_board_type {

 /* Global resources for unloading a previously loaded device */
 #define BNX2X_PREV_WAIT_NEEDED 1
-static DEFINE_SEMAPHORE(bnx2x_prev_sem);
+static DEFINE_BINARY_SEMAPHORE(bnx2x_prev_sem);
 static LIST_HEAD(bnx2x_prev_list);

 /* Forward declaration */
diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c
b/drivers/scsi/esas2r/esas2r_ioctl.c
index 9762300..55a9488 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -56,7 +56,7 @@
 u32 esas2r_buffered_ioctl_size;
 struct pci_dev *esas2r_buffered_ioctl_pcid;

-static DEFINE_SEMAPHORE(buffered_ioctl_semaphore);
+static DEFINE_BINARY_SEMAPHORE(buffered_ioctl_semaphore);
 typedef int (*BUFFERED_IOCTL_CALLBACK)(struct esas2r_adapter *,
         struct esas2r_request *,
         struct esas2r_sg_context *,
diff --git
a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index b59ef14..727ec59 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -84,7 +84,7 @@ struct vchiq_pagelist_info {
 static struct semaphore g_free_fragments_sema;
 static struct device *g_dev;

-static DEFINE_SEMAPHORE(g_free_fragments_mutex);
+static DEFINE_BINARY_SEMAPHORE(g_free_fragments_mutex);

 static irqreturn_t
 vchiq_doorbell_irq(int irq, void *dev_id);
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
index 11c86fb..b74522a 100644
--- a/include/linux/semaphore.h
+++ b/include/linux/semaphore.h
@@ -26,7 +26,7 @@ struct semaphore {
  .wait_list = LIST_HEAD_INIT((name).wait_list), \
 }

-#define DEFINE_SEMAPHORE(name) \
+#define DEFINE_BINARY_SEMAPHORE(name) \
  struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)

 static inline void sema_init(struct semaphore *sem, int val)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f274fbe..8cb2f27 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -78,7 +78,7 @@
  * provides serialisation for access to the entire console
  * driver system.
  */
-static DEFINE_SEMAPHORE(console_sem);
+static DEFINE_BINARY_SEMAPHORE(console_sem);
 struct console *console_drivers;
 EXPORT_SYMBOL_GPL(console_drivers);

-- 
1.9.1

-- 
 

This message contains confidential information and is intended only for the 
individual(s) named. If you are not the intended recipient, you are 
notified that disclosing, copying, distributing or taking any action in 
reliance on the contents of this mail and attached file/s is strictly 
prohibited. Please notify the sender immediately and delete this e-mail 
from your system. E-mail transmission cannot be guaranteed to be secured or 
error-free as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses. The sender therefore does 
not accept liability for any errors or omissions in the contents of this 
message, which arise as a result of e-mail transmission.

[-- Attachment #1.2: Type: text/html, Size: 9824 bytes --]

[-- Attachment #2: 0001-Replace-DEFINE_SEMAPHORE-with-DEFINE_BINARY_SEMAPHOR.patch --]
[-- Type: text/x-patch, Size: 6153 bytes --]

From 5cd7fc8db1c23c3d2dd66152d7620ed4fd1081e3 Mon Sep 17 00:00:00 2001
From: Wasim Nazir <wasim.nazir@pathpartnertech.com>
Date: Sat, 31 Mar 2018 18:04:06 +0530
Subject: [PATCH] Replace DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE

Signed-off-by: Wasim Nazir <wasim.nazir@pathpartnertech.com>
---
 arch/mips/cavium-octeon/setup.c                                    | 2 +-
 drivers/firmware/efi/runtime-wrappers.c                            | 2 +-
 drivers/firmware/efi/vars.c                                        | 2 +-
 drivers/hv/vmbus_drv.c                                             | 2 +-
 drivers/macintosh/adb.c                                            | 2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c                   | 2 +-
 drivers/scsi/esas2r/esas2r_ioctl.c                                 | 2 +-
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +-
 include/linux/semaphore.h                                          | 2 +-
 kernel/printk/printk.c                                             | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index a8034d0..983b464 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -68,7 +68,7 @@
 static unsigned long long max_memory = ULLONG_MAX;
 static unsigned long long reserve_low_mem;
 
-DEFINE_SEMAPHORE(octeon_bootbus_sem);
+DEFINE_BINARY_SEMAPHORE(octeon_bootbus_sem);
 EXPORT_SYMBOL(octeon_bootbus_sem);
 
 struct octeon_boot_descriptor *octeon_boot_desc_ptr;
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index ae54870b..5706f8c 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -88,7 +88,7 @@ void efi_call_virt_check_flags(unsigned long flags, const char *call)
  * none of the remaining functions are actually ever called at runtime.
  * So let's just use a single lock to serialize all Runtime Services calls.
  */
-static DEFINE_SEMAPHORE(efi_runtime_lock);
+static DEFINE_BINARY_SEMAPHORE(efi_runtime_lock);
 
 static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 {
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index 9336ffd..e8aab38 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -43,7 +43,7 @@
  * 2) ->ops calls
  * 3) (un)registration of __efivars
  */
-static DEFINE_SEMAPHORE(efivars_lock);
+static DEFINE_BINARY_SEMAPHORE(efivars_lock);
 
 static bool efivar_wq_enabled = true;
 DECLARE_WORK(efivar_work, NULL);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index bc65c4d..a75ad8a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -88,7 +88,7 @@ static int hyperv_die_event(struct notifier_block *nb, unsigned long val,
 static const char *fb_mmio_name = "fb_range";
 static struct resource *fb_mmio;
 static struct resource *hyperv_mmio;
-static DEFINE_SEMAPHORE(hyperv_mmio_lock);
+static DEFINE_BINARY_SEMAPHORE(hyperv_mmio_lock);
 
 static int vmbus_exists(void)
 {
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 4c8097e..55725e0 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -80,7 +80,7 @@
 BLOCKING_NOTIFIER_HEAD(adb_client_list);
 static int adb_got_sleep;
 static int adb_inited;
-static DEFINE_SEMAPHORE(adb_probe_mutex);
+static DEFINE_BINARY_SEMAPHORE(adb_probe_mutex);
 static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index b8388e9..eac1bf9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -283,7 +283,7 @@ enum bnx2x_board_type {
 
 /* Global resources for unloading a previously loaded device */
 #define BNX2X_PREV_WAIT_NEEDED 1
-static DEFINE_SEMAPHORE(bnx2x_prev_sem);
+static DEFINE_BINARY_SEMAPHORE(bnx2x_prev_sem);
 static LIST_HEAD(bnx2x_prev_list);
 
 /* Forward declaration */
diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
index 9762300..55a9488 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -56,7 +56,7 @@
 u32 esas2r_buffered_ioctl_size;
 struct pci_dev *esas2r_buffered_ioctl_pcid;
 
-static DEFINE_SEMAPHORE(buffered_ioctl_semaphore);
+static DEFINE_BINARY_SEMAPHORE(buffered_ioctl_semaphore);
 typedef int (*BUFFERED_IOCTL_CALLBACK)(struct esas2r_adapter *,
 				       struct esas2r_request *,
 				       struct esas2r_sg_context *,
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index b59ef14..727ec59 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -84,7 +84,7 @@ struct vchiq_pagelist_info {
 static struct semaphore g_free_fragments_sema;
 static struct device *g_dev;
 
-static DEFINE_SEMAPHORE(g_free_fragments_mutex);
+static DEFINE_BINARY_SEMAPHORE(g_free_fragments_mutex);
 
 static irqreturn_t
 vchiq_doorbell_irq(int irq, void *dev_id);
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
index 11c86fb..b74522a 100644
--- a/include/linux/semaphore.h
+++ b/include/linux/semaphore.h
@@ -26,7 +26,7 @@ struct semaphore {
 	.wait_list	= LIST_HEAD_INIT((name).wait_list),		\
 }
 
-#define DEFINE_SEMAPHORE(name)	\
+#define DEFINE_BINARY_SEMAPHORE(name)	\
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
 
 static inline void sema_init(struct semaphore *sem, int val)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f274fbe..8cb2f27 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -78,7 +78,7 @@
  * provides serialisation for access to the entire console
  * driver system.
  */
-static DEFINE_SEMAPHORE(console_sem);
+static DEFINE_BINARY_SEMAPHORE(console_sem);
 struct console *console_drivers;
 EXPORT_SYMBOL_GPL(console_drivers);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Patch to replace DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE
  2018-03-31 14:08 ` Greg Kroah-Hartman
@ 2018-03-31 17:26   ` Wasim Nazir
  0 siblings, 0 replies; 4+ messages in thread
From: Wasim Nazir @ 2018-03-31 17:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: jhogan, kys, linuxdrivers, linux-kernel, devel, linux-arm-kernel,
	Ralf Baechle, Ard Biesheuvel, Haiyang Zhang, Stephen Hemminger,
	Benjamin Herrenschmidt, Ariel Elior, everest-linux-l2,
	James E.J. Bottomley, Martin K. Petersen, Eric Anholt,
	Stefan Wahren, Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
	David Daney, Mihaela Muraru, Kishore KP, Sidong Yang, Al Viro,
	Phil Elwell, Ingo Molnar, Tycho Andersen, linux-mips, linux-efi,
	linuxppc-dev, netdev, linux-scsi, linux-rpi-kernel, devel

[-- Attachment #1: Type: text/plain, Size: 1795 bytes --]

No worries, thanks for the update!

On Sat, Mar 31, 2018, 7:38 PM Greg Kroah-Hartman <gregkh@linuxfoundation.org>
wrote:

> On Sat, Mar 31, 2018 at 07:16:21PM +0530, Wasim Nazir wrote:
> > This message contains confidential information and is intended only for
> the
> > individual(s) named. If you are not the intended recipient, you are
> > notified that disclosing, copying, distributing or taking any action in
> > reliance on the contents of this mail and attached file/s is strictly
> > prohibited. Please notify the sender immediately and delete this e-mail
> > from your system. E-mail transmission cannot be guaranteed to be secured
> or
> > error-free as information could be intercepted, corrupted, lost,
> destroyed,
> > arrive late or incomplete, or contain viruses. The sender therefore does
> > not accept liability for any errors or omissions in the contents of this
> > message, which arise as a result of e-mail transmission.
>
>
> This footer is not compatible with patches submitted to the kernel,
> sorry.  email is now deleted.
>
> greg k-h
>

-- 
 

This message contains confidential information and is intended only for the 
individual(s) named. If you are not the intended recipient, you are 
notified that disclosing, copying, distributing or taking any action in 
reliance on the contents of this mail and attached file/s is strictly 
prohibited. Please notify the sender immediately and delete this e-mail 
from your system. E-mail transmission cannot be guaranteed to be secured or 
error-free as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses. The sender therefore does 
not accept liability for any errors or omissions in the contents of this 
message, which arise as a result of e-mail transmission.

[-- Attachment #2: Type: text/html, Size: 2217 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Patch to replace DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE
  2018-03-31 13:46 Wasim Nazir
@ 2018-03-31 14:08 ` Greg Kroah-Hartman
  2018-03-31 17:26   ` Wasim Nazir
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2018-03-31 14:08 UTC (permalink / raw)
  To: Wasim Nazir
  Cc: jhogan, kys, linuxdrivers, linux-kernel, devel, linux-arm-kernel,
	Ralf Baechle, Ard Biesheuvel, Haiyang Zhang, Stephen Hemminger,
	Benjamin Herrenschmidt, Ariel Elior, everest-linux-l2,
	James E.J. Bottomley, Martin K. Petersen, Eric Anholt,
	Stefan Wahren, Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
	David Daney, Mihaela Muraru, Kishore KP, Sidong Yang, Al Viro,
	Phil Elwell, Ingo Molnar, Tycho Andersen, linux-mips, linux-efi,
	linuxppc-dev, netdev, linux-scsi, linux-rpi-kernel, devel

On Sat, Mar 31, 2018 at 07:16:21PM +0530, Wasim Nazir wrote:
> This message contains confidential information and is intended only for the 
> individual(s) named. If you are not the intended recipient, you are 
> notified that disclosing, copying, distributing or taking any action in 
> reliance on the contents of this mail and attached file/s is strictly 
> prohibited. Please notify the sender immediately and delete this e-mail 
> from your system. E-mail transmission cannot be guaranteed to be secured or 
> error-free as information could be intercepted, corrupted, lost, destroyed, 
> arrive late or incomplete, or contain viruses. The sender therefore does 
> not accept liability for any errors or omissions in the contents of this 
> message, which arise as a result of e-mail transmission.


This footer is not compatible with patches submitted to the kernel,
sorry.  email is now deleted.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Patch to replace DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE
@ 2018-03-31 13:46 Wasim Nazir
  2018-03-31 14:08 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Wasim Nazir @ 2018-03-31 13:46 UTC (permalink / raw)
  To: jhogan, kys, linuxdrivers, linux-kernel, devel, linux-arm-kernel
  Cc: Wasim Nazir, Ralf Baechle, Ard Biesheuvel, Haiyang Zhang,
	Stephen Hemminger, Benjamin Herrenschmidt, Ariel Elior,
	everest-linux-l2, James E.J. Bottomley, Martin K. Petersen,
	Eric Anholt, Stefan Wahren, Greg Kroah-Hartman, Petr Mladek,
	Sergey Senozhatsky, Steven Rostedt, David Daney, Mihaela Muraru,
	Kishore KP, Sidong Yang, Al Viro, Phil Elwell, Ingo Molnar,
	Tycho Andersen, linux-mips, linux-efi, linuxppc-dev, netdev,
	linux-scsi, linux-rpi-kernel, devel


[-- Attachment #1.1: Type: text/plain, Size: 7054 bytes --]

This patch replaces the macro DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE.
This is necessary because otherwise it makes confusion with counting
semaphore.

To apply the patch, in the root of a kernel tree use:
patch -p1 < 0001-Replace-DEFINE_SEMAPHORE-with-DEFINE_BINARY_SEMAPHOR.patch


Please let me know any feedback you have on this patch.

Thank You,
Wasim Nazir,
Software Engineer,
Pathpartner Technology Pvt. Ldt.


Signed-off-by: Wasim Nazir <wasim.nazir@pathpartnertech.com>
---
 arch/mips/cavium-octeon/setup.c                                    | 2 +-
 drivers/firmware/efi/runtime-wrappers.c                            | 2 +-
 drivers/firmware/efi/vars.c                                        | 2 +-
 drivers/hv/vmbus_drv.c                                             | 2 +-
 drivers/macintosh/adb.c                                            | 2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c                   | 2 +-
 drivers/scsi/esas2r/esas2r_ioctl.c                                 | 2 +-
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +-
 include/linux/semaphore.h                                          | 2 +-
 kernel/printk/printk.c                                             | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/mips/cavium-octeon/setup.c
b/arch/mips/cavium-octeon/setup.c
index a8034d0..983b464 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -68,7 +68,7 @@
 static unsigned long long max_memory = ULLONG_MAX;
 static unsigned long long reserve_low_mem;

-DEFINE_SEMAPHORE(octeon_bootbus_sem);
+DEFINE_BINARY_SEMAPHORE(octeon_bootbus_sem);
 EXPORT_SYMBOL(octeon_bootbus_sem);

 struct octeon_boot_descriptor *octeon_boot_desc_ptr;
diff --git a/drivers/firmware/efi/runtime-wrappers.c
b/drivers/firmware/efi/runtime-wrappers.c
index ae54870b..5706f8c 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -88,7 +88,7 @@ void efi_call_virt_check_flags(unsigned long flags, const
char *call)
  * none of the remaining functions are actually ever called at runtime.
  * So let's just use a single lock to serialize all Runtime Services calls.
  */
-static DEFINE_SEMAPHORE(efi_runtime_lock);
+static DEFINE_BINARY_SEMAPHORE(efi_runtime_lock);

 static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 {
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index 9336ffd..e8aab38 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -43,7 +43,7 @@
  * 2) ->ops calls
  * 3) (un)registration of __efivars
  */
-static DEFINE_SEMAPHORE(efivars_lock);
+static DEFINE_BINARY_SEMAPHORE(efivars_lock);

 static bool efivar_wq_enabled = true;
 DECLARE_WORK(efivar_work, NULL);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index bc65c4d..a75ad8a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -88,7 +88,7 @@ static int hyperv_die_event(struct notifier_block *nb,
unsigned long val,
 static const char *fb_mmio_name = "fb_range";
 static struct resource *fb_mmio;
 static struct resource *hyperv_mmio;
-static DEFINE_SEMAPHORE(hyperv_mmio_lock);
+static DEFINE_BINARY_SEMAPHORE(hyperv_mmio_lock);

 static int vmbus_exists(void)
 {
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 4c8097e..55725e0 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -80,7 +80,7 @@
 BLOCKING_NOTIFIER_HEAD(adb_client_list);
 static int adb_got_sleep;
 static int adb_inited;
-static DEFINE_SEMAPHORE(adb_probe_mutex);
+static DEFINE_BINARY_SEMAPHORE(adb_probe_mutex);
 static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index b8388e9..eac1bf9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -283,7 +283,7 @@ enum bnx2x_board_type {

 /* Global resources for unloading a previously loaded device */
 #define BNX2X_PREV_WAIT_NEEDED 1
-static DEFINE_SEMAPHORE(bnx2x_prev_sem);
+static DEFINE_BINARY_SEMAPHORE(bnx2x_prev_sem);
 static LIST_HEAD(bnx2x_prev_list);

 /* Forward declaration */
diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c
b/drivers/scsi/esas2r/esas2r_ioctl.c
index 9762300..55a9488 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -56,7 +56,7 @@
 u32 esas2r_buffered_ioctl_size;
 struct pci_dev *esas2r_buffered_ioctl_pcid;

-static DEFINE_SEMAPHORE(buffered_ioctl_semaphore);
+static DEFINE_BINARY_SEMAPHORE(buffered_ioctl_semaphore);
 typedef int (*BUFFERED_IOCTL_CALLBACK)(struct esas2r_adapter *,
         struct esas2r_request *,
         struct esas2r_sg_context *,
diff --git
a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index b59ef14..727ec59 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -84,7 +84,7 @@ struct vchiq_pagelist_info {
 static struct semaphore g_free_fragments_sema;
 static struct device *g_dev;

-static DEFINE_SEMAPHORE(g_free_fragments_mutex);
+static DEFINE_BINARY_SEMAPHORE(g_free_fragments_mutex);

 static irqreturn_t
 vchiq_doorbell_irq(int irq, void *dev_id);
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
index 11c86fb..b74522a 100644
--- a/include/linux/semaphore.h
+++ b/include/linux/semaphore.h
@@ -26,7 +26,7 @@ struct semaphore {
  .wait_list = LIST_HEAD_INIT((name).wait_list), \
 }

-#define DEFINE_SEMAPHORE(name) \
+#define DEFINE_BINARY_SEMAPHORE(name) \
  struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)

 static inline void sema_init(struct semaphore *sem, int val)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f274fbe..8cb2f27 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -78,7 +78,7 @@
  * provides serialisation for access to the entire console
  * driver system.
  */
-static DEFINE_SEMAPHORE(console_sem);
+static DEFINE_BINARY_SEMAPHORE(console_sem);
 struct console *console_drivers;
 EXPORT_SYMBOL_GPL(console_drivers);

-- 
1.9.1

-- 
 

This message contains confidential information and is intended only for the 
individual(s) named. If you are not the intended recipient, you are 
notified that disclosing, copying, distributing or taking any action in 
reliance on the contents of this mail and attached file/s is strictly 
prohibited. Please notify the sender immediately and delete this e-mail 
from your system. E-mail transmission cannot be guaranteed to be secured or 
error-free as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses. The sender therefore does 
not accept liability for any errors or omissions in the contents of this 
message, which arise as a result of e-mail transmission.

[-- Attachment #1.2: Type: text/html, Size: 20690 bytes --]

[-- Attachment #2: 0001-Replace-DEFINE_SEMAPHORE-with-DEFINE_BINARY_SEMAPHOR.patch --]
[-- Type: text/x-patch, Size: 6153 bytes --]

From 5cd7fc8db1c23c3d2dd66152d7620ed4fd1081e3 Mon Sep 17 00:00:00 2001
From: Wasim Nazir <wasim.nazir@pathpartnertech.com>
Date: Sat, 31 Mar 2018 18:04:06 +0530
Subject: [PATCH] Replace DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE

Signed-off-by: Wasim Nazir <wasim.nazir@pathpartnertech.com>
---
 arch/mips/cavium-octeon/setup.c                                    | 2 +-
 drivers/firmware/efi/runtime-wrappers.c                            | 2 +-
 drivers/firmware/efi/vars.c                                        | 2 +-
 drivers/hv/vmbus_drv.c                                             | 2 +-
 drivers/macintosh/adb.c                                            | 2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c                   | 2 +-
 drivers/scsi/esas2r/esas2r_ioctl.c                                 | 2 +-
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +-
 include/linux/semaphore.h                                          | 2 +-
 kernel/printk/printk.c                                             | 2 +-
 10 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index a8034d0..983b464 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -68,7 +68,7 @@
 static unsigned long long max_memory = ULLONG_MAX;
 static unsigned long long reserve_low_mem;
 
-DEFINE_SEMAPHORE(octeon_bootbus_sem);
+DEFINE_BINARY_SEMAPHORE(octeon_bootbus_sem);
 EXPORT_SYMBOL(octeon_bootbus_sem);
 
 struct octeon_boot_descriptor *octeon_boot_desc_ptr;
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index ae54870b..5706f8c 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -88,7 +88,7 @@ void efi_call_virt_check_flags(unsigned long flags, const char *call)
  * none of the remaining functions are actually ever called at runtime.
  * So let's just use a single lock to serialize all Runtime Services calls.
  */
-static DEFINE_SEMAPHORE(efi_runtime_lock);
+static DEFINE_BINARY_SEMAPHORE(efi_runtime_lock);
 
 static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 {
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index 9336ffd..e8aab38 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -43,7 +43,7 @@
  * 2) ->ops calls
  * 3) (un)registration of __efivars
  */
-static DEFINE_SEMAPHORE(efivars_lock);
+static DEFINE_BINARY_SEMAPHORE(efivars_lock);
 
 static bool efivar_wq_enabled = true;
 DECLARE_WORK(efivar_work, NULL);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index bc65c4d..a75ad8a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -88,7 +88,7 @@ static int hyperv_die_event(struct notifier_block *nb, unsigned long val,
 static const char *fb_mmio_name = "fb_range";
 static struct resource *fb_mmio;
 static struct resource *hyperv_mmio;
-static DEFINE_SEMAPHORE(hyperv_mmio_lock);
+static DEFINE_BINARY_SEMAPHORE(hyperv_mmio_lock);
 
 static int vmbus_exists(void)
 {
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 4c8097e..55725e0 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -80,7 +80,7 @@
 BLOCKING_NOTIFIER_HEAD(adb_client_list);
 static int adb_got_sleep;
 static int adb_inited;
-static DEFINE_SEMAPHORE(adb_probe_mutex);
+static DEFINE_BINARY_SEMAPHORE(adb_probe_mutex);
 static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index b8388e9..eac1bf9 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -283,7 +283,7 @@ enum bnx2x_board_type {
 
 /* Global resources for unloading a previously loaded device */
 #define BNX2X_PREV_WAIT_NEEDED 1
-static DEFINE_SEMAPHORE(bnx2x_prev_sem);
+static DEFINE_BINARY_SEMAPHORE(bnx2x_prev_sem);
 static LIST_HEAD(bnx2x_prev_list);
 
 /* Forward declaration */
diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
index 9762300..55a9488 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -56,7 +56,7 @@
 u32 esas2r_buffered_ioctl_size;
 struct pci_dev *esas2r_buffered_ioctl_pcid;
 
-static DEFINE_SEMAPHORE(buffered_ioctl_semaphore);
+static DEFINE_BINARY_SEMAPHORE(buffered_ioctl_semaphore);
 typedef int (*BUFFERED_IOCTL_CALLBACK)(struct esas2r_adapter *,
 				       struct esas2r_request *,
 				       struct esas2r_sg_context *,
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index b59ef14..727ec59 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -84,7 +84,7 @@ struct vchiq_pagelist_info {
 static struct semaphore g_free_fragments_sema;
 static struct device *g_dev;
 
-static DEFINE_SEMAPHORE(g_free_fragments_mutex);
+static DEFINE_BINARY_SEMAPHORE(g_free_fragments_mutex);
 
 static irqreturn_t
 vchiq_doorbell_irq(int irq, void *dev_id);
diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
index 11c86fb..b74522a 100644
--- a/include/linux/semaphore.h
+++ b/include/linux/semaphore.h
@@ -26,7 +26,7 @@ struct semaphore {
 	.wait_list	= LIST_HEAD_INIT((name).wait_list),		\
 }
 
-#define DEFINE_SEMAPHORE(name)	\
+#define DEFINE_BINARY_SEMAPHORE(name)	\
 	struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
 
 static inline void sema_init(struct semaphore *sem, int val)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index f274fbe..8cb2f27 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -78,7 +78,7 @@
  * provides serialisation for access to the entire console
  * driver system.
  */
-static DEFINE_SEMAPHORE(console_sem);
+static DEFINE_BINARY_SEMAPHORE(console_sem);
 struct console *console_drivers;
 EXPORT_SYMBOL_GPL(console_drivers);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-31 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-31 13:34 [PATCH] Patch to replace DEFINE_SEMAPHORE with DEFINE_BINARY_SEMAPHORE Wasim Nazir
2018-03-31 13:46 Wasim Nazir
2018-03-31 14:08 ` Greg Kroah-Hartman
2018-03-31 17:26   ` Wasim Nazir

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).