Re: [PATCH -next 5/5] USB: usbip: Remove an unnecessary NULL value

2023-08-04 Thread Ruan Jinjie



On 2023/8/5 4:09, shuah wrote:
> On 8/4/23 03:32, Ruan Jinjie wrote:
>> The NULL initialization of the pointers assigned by kzalloc() first is
>> not necessary, because if the kzalloc() failed, the pointers will be
>> assigned NULL, otherwise it works as usual. so remove it.
>>
>> Signed-off-by: Ruan Jinjie 
>> ---
>>   drivers/usb/usbip/vudc_dev.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
>> index 2bc428f2e261..8e42839e6060 100644
>> --- a/drivers/usb/usbip/vudc_dev.c
>> +++ b/drivers/usb/usbip/vudc_dev.c
>> @@ -489,7 +489,7 @@ static void vudc_device_unusable(struct
>> usbip_device *ud)
>>     struct vudc_device *alloc_vudc_device(int devid)
>>   {
>> -    struct vudc_device *udc_dev = NULL;
>> +    struct vudc_device *udc_dev;
>>     udc_dev = kzalloc(sizeof(*udc_dev), GFP_KERNEL);
>>   if (!udc_dev)
> 
> In addition to this, make a change to return NULL instead
> of going to out.
> 
> if (!udc_dev)
>     goto out;

Thank you! I'll research it and fix sooner.

> 
> thanks,
> -- Shuah
> 


[PATCH -next 4/5] usb: musb: Remove an unnecessary NULL value

2023-08-04 Thread Ruan Jinjie
The NULL initialization of the pointers assigned by kzalloc() first is
not necessary, because if the kzalloc() failed, the pointers will be
assigned NULL, otherwise it works as usual. so remove it.

Signed-off-by: Ruan Jinjie 
---
 drivers/usb/musb/musb_gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index 31c44325e828..051c6da7cf6d 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1130,7 +1130,7 @@ static int musb_gadget_disable(struct usb_ep *ep)
 struct usb_request *musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
 {
struct musb_ep  *musb_ep = to_musb_ep(ep);
-   struct musb_request *request = NULL;
+   struct musb_request *request;
 
request = kzalloc(sizeof *request, gfp_flags);
if (!request)
-- 
2.34.1



[PATCH -next 5/5] USB: usbip: Remove an unnecessary NULL value

2023-08-04 Thread Ruan Jinjie
The NULL initialization of the pointers assigned by kzalloc() first is
not necessary, because if the kzalloc() failed, the pointers will be
assigned NULL, otherwise it works as usual. so remove it.

Signed-off-by: Ruan Jinjie 
---
 drivers/usb/usbip/vudc_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
index 2bc428f2e261..8e42839e6060 100644
--- a/drivers/usb/usbip/vudc_dev.c
+++ b/drivers/usb/usbip/vudc_dev.c
@@ -489,7 +489,7 @@ static void vudc_device_unusable(struct usbip_device *ud)
 
 struct vudc_device *alloc_vudc_device(int devid)
 {
-   struct vudc_device *udc_dev = NULL;
+   struct vudc_device *udc_dev;
 
udc_dev = kzalloc(sizeof(*udc_dev), GFP_KERNEL);
if (!udc_dev)
-- 
2.34.1



[PATCH -next 1/5] usb: gadget: udc: Remove unnecessary NULL values

2023-08-04 Thread Ruan Jinjie
The NULL initialization of the pointers assigned by kzalloc() first is
not necessary, because if the kzalloc() failed, the pointers will be
assigned NULL, otherwise it works as usual. so remove it.

Signed-off-by: Ruan Jinjie 
---
 drivers/usb/gadget/udc/fsl_udc_core.c | 2 +-
 drivers/usb/gadget/udc/mv_u3d_core.c  | 4 ++--
 drivers/usb/gadget/udc/mv_udc_core.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c 
b/drivers/usb/gadget/udc/fsl_udc_core.c
index 5265ca418cde..ee5705d336e3 100644
--- a/drivers/usb/gadget/udc/fsl_udc_core.c
+++ b/drivers/usb/gadget/udc/fsl_udc_core.c
@@ -671,7 +671,7 @@ static int fsl_ep_disable(struct usb_ep *_ep)
 static struct usb_request *
 fsl_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
 {
-   struct fsl_req *req = NULL;
+   struct fsl_req *req;
 
req = kzalloc(sizeof *req, gfp_flags);
if (!req)
diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c 
b/drivers/usb/gadget/udc/mv_u3d_core.c
index 3473048a85f5..2a421f0ff931 100644
--- a/drivers/usb/gadget/udc/mv_u3d_core.c
+++ b/drivers/usb/gadget/udc/mv_u3d_core.c
@@ -665,7 +665,7 @@ static int  mv_u3d_ep_disable(struct usb_ep *_ep)
 static struct usb_request *
 mv_u3d_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
 {
-   struct mv_u3d_req *req = NULL;
+   struct mv_u3d_req *req;
 
req = kzalloc(sizeof *req, gfp_flags);
if (!req)
@@ -1779,7 +1779,7 @@ static void mv_u3d_remove(struct platform_device *dev)
 
 static int mv_u3d_probe(struct platform_device *dev)
 {
-   struct mv_u3d *u3d = NULL;
+   struct mv_u3d *u3d;
struct mv_usb_platform_data *pdata = dev_get_platdata(>dev);
int retval = 0;
struct resource *r;
diff --git a/drivers/usb/gadget/udc/mv_udc_core.c 
b/drivers/usb/gadget/udc/mv_udc_core.c
index 79db74e2040b..d888dcda2bc8 100644
--- a/drivers/usb/gadget/udc/mv_udc_core.c
+++ b/drivers/usb/gadget/udc/mv_udc_core.c
@@ -595,7 +595,7 @@ static int  mv_ep_disable(struct usb_ep *_ep)
 static struct usb_request *
 mv_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
 {
-   struct mv_req *req = NULL;
+   struct mv_req *req;
 
req = kzalloc(sizeof *req, gfp_flags);
if (!req)
-- 
2.34.1



[PATCH -next 0/5] usb: Remove many unnecessary NULL values

2023-08-04 Thread Ruan Jinjie
The NULL initialization of the pointers assigned by kzalloc() first is
not necessary, because if the kzalloc() failed, the pointers will be
assigned NULL, otherwise it works as usual. so remove it.

Ruan Jinjie (5):
  usb: gadget: udc: Remove unnecessary NULL values
  USB: misc: Remove unnecessary NULL values
  usb: chipidea: udc: Remove an unnecessary NULL value
  usb: musb: Remove an unnecessary NULL value
  USB: usbip: Remove an unnecessary NULL value

 drivers/usb/chipidea/udc.c| 2 +-
 drivers/usb/gadget/udc/fsl_udc_core.c | 2 +-
 drivers/usb/gadget/udc/mv_u3d_core.c  | 4 ++--
 drivers/usb/gadget/udc/mv_udc_core.c  | 2 +-
 drivers/usb/misc/cypress_cy7c63.c | 2 +-
 drivers/usb/misc/cytherm.c| 2 +-
 drivers/usb/misc/usbsevseg.c  | 2 +-
 drivers/usb/musb/musb_gadget.c| 2 +-
 drivers/usb/usbip/vudc_dev.c  | 2 +-
 9 files changed, 10 insertions(+), 10 deletions(-)

-- 
2.34.1



[PATCH -next 3/5] usb: chipidea: udc: Remove an unnecessary NULL value

2023-08-04 Thread Ruan Jinjie
The NULL initialization of the pointers assigned by kzalloc() first is
not necessary, because if the kzalloc() failed, the pointers will be
assigned NULL, otherwise it works as usual. so remove it.

Signed-off-by: Ruan Jinjie 
---
 drivers/usb/chipidea/udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index d58355427eeb..0b7bd3c643c3 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1463,7 +1463,7 @@ static int ep_disable(struct usb_ep *ep)
  */
 static struct usb_request *ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
 {
-   struct ci_hw_req *hwreq = NULL;
+   struct ci_hw_req *hwreq;
 
if (ep == NULL)
return NULL;
-- 
2.34.1



[PATCH -next 2/5] USB: misc: Remove unnecessary NULL values

2023-08-04 Thread Ruan Jinjie
The NULL initialization of the pointers assigned by kzalloc() first is
not necessary, because if the kzalloc() failed, the pointers will be
assigned NULL, otherwise it works as usual. so remove it.

Signed-off-by: Ruan Jinjie 
---
 drivers/usb/misc/cypress_cy7c63.c | 2 +-
 drivers/usb/misc/cytherm.c| 2 +-
 drivers/usb/misc/usbsevseg.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/misc/cypress_cy7c63.c 
b/drivers/usb/misc/cypress_cy7c63.c
index 14faec51d7a5..cecd7693b741 100644
--- a/drivers/usb/misc/cypress_cy7c63.c
+++ b/drivers/usb/misc/cypress_cy7c63.c
@@ -203,7 +203,7 @@ ATTRIBUTE_GROUPS(cypress);
 static int cypress_probe(struct usb_interface *interface,
 const struct usb_device_id *id)
 {
-   struct cypress *dev = NULL;
+   struct cypress *dev;
int retval = -ENOMEM;
 
/* allocate memory for our device state and initialize it */
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index 3e3802aaefa3..918833b471ea 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -304,7 +304,7 @@ static int cytherm_probe(struct usb_interface *interface,
 const struct usb_device_id *id)
 {
struct usb_device *udev = interface_to_usbdev(interface);
-   struct usb_cytherm *dev = NULL;
+   struct usb_cytherm *dev;
int retval = -ENOMEM;
 
dev = kzalloc (sizeof(struct usb_cytherm), GFP_KERNEL);
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c
index c3114d9bd128..546deff754ba 100644
--- a/drivers/usb/misc/usbsevseg.c
+++ b/drivers/usb/misc/usbsevseg.c
@@ -305,7 +305,7 @@ static int sevseg_probe(struct usb_interface *interface,
const struct usb_device_id *id)
 {
struct usb_device *udev = interface_to_usbdev(interface);
-   struct usb_sevsegdev *mydev = NULL;
+   struct usb_sevsegdev *mydev;
int rc = -ENOMEM;
 
mydev = kzalloc(sizeof(struct usb_sevsegdev), GFP_KERNEL);
-- 
2.34.1



[PATCH -next 0/2] soc: Do not check for 0 return after calling platform_get_irq()

2023-08-03 Thread Ruan Jinjie
Since commit ce753ad1549c ("platform: finally disallow IRQ0 in
platform_get_irq() and its ilk"), there is no possible for
platform_get_irq() to return 0.

And the return value of platform_get_irq() is
more sensible to show the error reason.

Ruan Jinjie (2):
  soc: fsl: qe: Do not check for 0 return after calling
platform_get_irq()
  soc: xilinx: Do not check for 0 return after calling
platform_get_irq()

 drivers/soc/fsl/qe/qe_ic.c| 4 ++--
 drivers/soc/xilinx/zynqmp_power.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

-- 
2.34.1



[PATCH -next 1/2] soc: fsl: qe: Do not check for 0 return after calling platform_get_irq()

2023-08-03 Thread Ruan Jinjie
There is no possible for platform_get_irq() to
return 0. Use the return value from platform_get_irq().

Signed-off-by: Ruan Jinjie 
---
 drivers/soc/fsl/qe/qe_ic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/fsl/qe/qe_ic.c b/drivers/soc/fsl/qe/qe_ic.c
index bbae3d39c7be..8ab6e51e4f28 100644
--- a/drivers/soc/fsl/qe/qe_ic.c
+++ b/drivers/soc/fsl/qe/qe_ic.c
@@ -435,8 +435,8 @@ static int qe_ic_init(struct platform_device *pdev)
qe_ic->virq_high = platform_get_irq(pdev, 0);
qe_ic->virq_low = platform_get_irq(pdev, 1);
 
-   if (qe_ic->virq_low <= 0)
-   return -ENODEV;
+   if (qe_ic->virq_low < 0)
+   return qe_ic->virq_low;
 
if (qe_ic->virq_high > 0 && qe_ic->virq_high != qe_ic->virq_low) {
low_handler = qe_ic_cascade_low;
-- 
2.34.1



[PATCH -next 2/2] soc: xilinx: Do not check for 0 return after calling platform_get_irq()

2023-08-03 Thread Ruan Jinjie
There is no possible for platform_get_irq() to
return 0. Use the return value from platform_get_irq().

Signed-off-by: Ruan Jinjie 
---
 drivers/soc/xilinx/zynqmp_power.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/xilinx/zynqmp_power.c 
b/drivers/soc/xilinx/zynqmp_power.c
index 641dcc958911..eddfc8141a42 100644
--- a/drivers/soc/xilinx/zynqmp_power.c
+++ b/drivers/soc/xilinx/zynqmp_power.c
@@ -242,8 +242,8 @@ static int zynqmp_pm_probe(struct platform_device *pdev)
}
} else if (of_property_present(pdev->dev.of_node, "interrupts")) {
irq = platform_get_irq(pdev, 0);
-   if (irq <= 0)
-   return -ENXIO;
+   if (irq < 0)
+   return irq;
 
ret = devm_request_threaded_irq(>dev, irq, NULL,
zynqmp_pm_isr,
-- 
2.34.1



Re: [PATCH -next v2] powerpc/mpic_msgr: fix cast removes address space of expression warnings

2022-10-28 Thread Ruan Jinjie
Ping.

On 2022/10/19 14:34, ruanjinjie wrote:
> When build Linux kernel, encounter the following warnings:
> 
> ./arch/powerpc/sysdev/mpic_msgr.c:230:38: warning: cast removes address space 
> '__iomem' of expression
> ./arch/powerpc/sysdev/mpic_msgr.c:230:27: warning: incorrect type in 
> assignment (different address spaces)
> 
> The data type of msgr->mer and msgr->base are 'u32 __iomem *', but
> converted to 'u32 *' and 'u8 *' directly and cause above warnings, now
> instead of using a type cast, change the size of the pointer offset to fix
> these warnings.
> 
> Signed-off-by: ruanjinjie 
> ---
> v2:
> - change the macro of MPIC_MSGR_MER_OFFSET to avoid type cast and
>   simplify the fix
> ---
>  arch/powerpc/sysdev/mpic_msgr.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/sysdev/mpic_msgr.c b/arch/powerpc/sysdev/mpic_msgr.c
> index a439e33eae06..d75064fb7d12 100644
> --- a/arch/powerpc/sysdev/mpic_msgr.c
> +++ b/arch/powerpc/sysdev/mpic_msgr.c
> @@ -20,7 +20,7 @@
>  
>  #define MPIC_MSGR_REGISTERS_PER_BLOCK4
>  #define MPIC_MSGR_STRIDE 0x10
> -#define MPIC_MSGR_MER_OFFSET 0x100
> +#define MPIC_MSGR_MER_OFFSET (0x100 / sizeof(u32))
>  #define MSGR_INUSE   0
>  #define MSGR_FREE1
>  
> @@ -234,7 +234,7 @@ static int mpic_msgr_probe(struct platform_device *dev)
>  
>   reg_number = block_number * MPIC_MSGR_REGISTERS_PER_BLOCK + i;
>   msgr->base = msgr_block_addr + i * MPIC_MSGR_STRIDE;
> - msgr->mer = (u32 *)((u8 *)msgr->base + MPIC_MSGR_MER_OFFSET);
> + msgr->mer = msgr->base + MPIC_MSGR_MER_OFFSET;
>   msgr->in_use = MSGR_FREE;
>   msgr->num = i;
>   raw_spin_lock_init(>lock);


Re: [PATCH -next] powerpc/mpic_msgr: fix cast removes address space of expression warnings

2022-09-30 Thread Ruan Jinjie



On 2022/9/30 14:09, Christophe Leroy wrote:
> 
> 
> Le 01/09/2022 à 10:54, ruanjinjie a écrit :
>> [Vous ne recevez pas souvent de courriers de ruanjin...@huawei.com. 
>> Découvrez pourquoi ceci est important à 
>> https://aka.ms/LearnAboutSenderIdentification ]
>>
>> When build Linux kernel, encounter the following warnings:
>>
>> ./arch/powerpc/sysdev/mpic_msgr.c:230:38: warning: cast removes address 
>> space '__iomem' of expression
>> ./arch/powerpc/sysdev/mpic_msgr.c:230:27: warning: incorrect type in 
>> assignment (different address spaces)
>>
>> The data type of msgr->mer and msgr->base are 'u32 __iomem *', but
>> converted to 'u32 *' and 'u8 *' directly and cause above warnings, now
>> recover their data types to fix these warnings.
> 
> I think the best would be to change MPIC_MSGR_MER_OFFSET to 0x40 and 
> then drop the casts completely:
> 
>   msgr->mer = msgr->base + MPIC_MSGR_MER_OFFSET;
> 
I think this is good to solve the warning.

>>
>> Signed-off-by: ruanjinjie 
>> ---
>>   arch/powerpc/sysdev/mpic_msgr.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/powerpc/sysdev/mpic_msgr.c 
>> b/arch/powerpc/sysdev/mpic_msgr.c
>> index 698fefaaa6dd..cbb0d24f15ba 100644
>> --- a/arch/powerpc/sysdev/mpic_msgr.c
>> +++ b/arch/powerpc/sysdev/mpic_msgr.c
>> @@ -227,7 +227,7 @@ static int mpic_msgr_probe(struct platform_device *dev)
>>
>>  reg_number = block_number * MPIC_MSGR_REGISTERS_PER_BLOCK + 
>> i;
>>  msgr->base = msgr_block_addr + i * MPIC_MSGR_STRIDE;
>> -   msgr->mer = (u32 *)((u8 *)msgr->base + MPIC_MSGR_MER_OFFSET);
>> +   msgr->mer = (u32 __iomem *)((u8 __iomem *)msgr->base + 
>> MPIC_MSGR_MER_OFFSET);
>>  msgr->in_use = MSGR_FREE;
>>  msgr->num = i;
>>  raw_spin_lock_init(>lock);
>> --
>> 2.25.1


Re: [PATCH -next] powerpc/mpic_msgr: fix cast removes address space of expression warnings

2022-09-29 Thread Ruan Jinjie
Ping.

On 2022/9/1 16:54, ruanjinjie wrote:
> When build Linux kernel, encounter the following warnings:
> 
> ./arch/powerpc/sysdev/mpic_msgr.c:230:38: warning: cast removes address space 
> '__iomem' of expression
> ./arch/powerpc/sysdev/mpic_msgr.c:230:27: warning: incorrect type in 
> assignment (different address spaces)
> 
> The data type of msgr->mer and msgr->base are 'u32 __iomem *', but
> converted to 'u32 *' and 'u8 *' directly and cause above warnings, now
> recover their data types to fix these warnings.
> 
> Signed-off-by: ruanjinjie 
> ---
>  arch/powerpc/sysdev/mpic_msgr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/sysdev/mpic_msgr.c b/arch/powerpc/sysdev/mpic_msgr.c
> index 698fefaaa6dd..cbb0d24f15ba 100644
> --- a/arch/powerpc/sysdev/mpic_msgr.c
> +++ b/arch/powerpc/sysdev/mpic_msgr.c
> @@ -227,7 +227,7 @@ static int mpic_msgr_probe(struct platform_device *dev)
>  
>   reg_number = block_number * MPIC_MSGR_REGISTERS_PER_BLOCK + i;
>   msgr->base = msgr_block_addr + i * MPIC_MSGR_STRIDE;
> - msgr->mer = (u32 *)((u8 *)msgr->base + MPIC_MSGR_MER_OFFSET);
> + msgr->mer = (u32 __iomem *)((u8 __iomem *)msgr->base + 
> MPIC_MSGR_MER_OFFSET);
>   msgr->in_use = MSGR_FREE;
>   msgr->num = i;
>   raw_spin_lock_init(>lock);