[PATCH] Staging : rtl8188eu : rtw_security.c - Fixed warning: coding style issues - Fixed warning: if statement containing return with an else - Fixed check: coding style issues

2019-08-05 Thread merwintf
Signed-off-by: merwintf 
---
 drivers/staging/rtl8188eu/core/rtw_security.c | 525 +++---
 1 file changed, 334 insertions(+), 191 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c 
b/drivers/staging/rtl8188eu/core/rtw_security.c
index 2f90f60f1681..b9f5ebdae034 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -67,7 +67,8 @@ static u32 arcfour_byte(struct arc4context *parc4ctx)
return state[(sx + sy) & 0xff];
 }
 
-static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, 
u32 len)
+static void arcfour_encrypt(struct arc4context *parc4ctx,
+   u8 *dest, u8 *src, u32 len)
 {
u32 i;
 
@@ -80,16 +81,19 @@ static u32 crc32_table[256];
 
 static u8 crc32_reverseBit(u8 data)
 {
-   return (u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) |
-  ((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) |
-  ((data>>5)&0x02) | ((data>>7)&0x01);
+   return (u8)((data << 7) & 0x80)
+| ((data << 5) & 0x40)
+| ((data << 3) & 0x20)
+| ((data << 1) & 0x10)
+| ((data >> 1) & 0x08)
+| ((data >> 3) & 0x04)
+| ((data >> 5) & 0x02)
+| ((data >> 7) & 0x01);
 }
 
 static void crc32_init(void)
 {
-   if (bcrc32initialized == 1) {
-   return;
-   } else {
+   if (bcrc32initialized != 1) {
int i, j;
u32 c;
u8 *p = (u8 *)&c, *p1;
@@ -100,7 +104,8 @@ static void crc32_init(void)
for (i = 0; i < 256; ++i) {
k = crc32_reverseBit((u8)i);
for (c = ((u32)k) << 24, j = 8; j > 0; --j)
-   c = c & 0x8000 ? (c << 1) ^ CRC32_POLY : (c 
<< 1);
+   c = c & 0x8000 ?
+   (c << 1) ^ CRC32_POLY : (c << 1);
p1 = (u8 *)&crc32_table[i];
 
p1[0] = crc32_reverseBit(p[3]);
@@ -119,23 +124,26 @@ static __le32 getcrc32(u8 *buf, int len)
 
if (bcrc32initialized == 0)
crc32_init();
-
-   crc = 0x;   /* preload shift register, per CRC-32 spec */
+   /* preload shift register, per CRC-32 spec */
+   crc = 0x;
 
for (p = buf; len > 0; ++p, --len)
crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8);
-   return cpu_to_le32(~crc);/* transmit complement, per CRC-32 spec */
+   /* transmit complement, per CRC-32 spec */
+   return cpu_to_le32(~crc);
 }
 
 /*
-   Need to consider the fragment  situation
-*/
+ * Need to consider the fragment  situation
+ */
 void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe)
 {
int curfragnum, length;
u8 *pframe;
u8 hw_hdr_offset = 0;
-   struct  pkt_attrib   *pattrib = &((struct xmit_frame 
*)pxmitframe)->attrib;
+   struct  pkt_attrib   *pattrib =
+   &((struct xmit_frame *)pxmitframe)->attrib;
+
struct  security_priv   *psecuritypriv = &padapter->securitypriv;
struct  xmit_priv   *pxmitpriv = &padapter->xmitpriv;
const int keyindex = psecuritypriv->dot11PrivacyKeyIndex;
@@ -150,7 +158,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 
*pxmitframe)
return;
 
hw_hdr_offset = TXDESC_SIZE +
-(((struct xmit_frame *)pxmitframe)->pkt_offset * 
PACKET_OFFSET_SZ);
+   (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ);
 
pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset;
 
@@ -164,7 +172,8 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 
*pxmitframe)
return;
 
if (crypto_ops->set_key(psecuritypriv->dot11DefKey[keyindex].skey,
-   psecuritypriv->dot11DefKeylen[keyindex], NULL, 
crypto_private) < 0)
+   psecuritypriv->dot11DefKeylen[keyindex],
+   NULL, crypto_private) < 0)
goto free_crypto_private;
 
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
@@ -182,7 +191,8 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 
*pxmitframe)
skb_pull(skb, 4);
skb_trim(skb, skb->len - 4);
 
-   if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen, 
crypto_private)) {
+   if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen,
+crypto_private)) {
kfree_skb(skb);
goto free_crypto_private;
}
@@ -201,16 +211,20 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 
*pxmitframe)
 
 int rtw_wep_decrypt(struct adapter  *padapter, u8 *precvframe)
 {
-  

Re: [PATCH] Staging : rtl8188eu : rtw_security.c - Fixed warning: coding style issues - Fixed warning: if statement containing return with an else - Fixed check: coding style issues

2019-08-05 Thread Greg KH
On Mon, Aug 05, 2019 at 01:22:56PM +0530, merwintf wrote:
> Signed-off-by: merwintf 
> ---
>  drivers/staging/rtl8188eu/core/rtw_security.c | 525 +++---
>  1 file changed, 334 insertions(+), 191 deletions(-)
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch did many different things all at once, making it difficult
  to review.  All Linux kernel patches need to only do one thing at a
  time.  If you need to do multiple things (such as clean up all coding
  style issues in a file/driver), do it in a sequence of patches, each
  one doing only one thing.  This will make it easier to review the
  patches to ensure that they are correct, and to help alleviate any
  merge issues that larger patches can cause.

- You did not specify a description of why the patch is needed, or
  possibly, any description at all, in the email body.  Please read the
  section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what is needed in order to
  properly describe the change.

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/SubmittingPatches for what a proper Subject: line should
  look like.

- It looks like you did not use your "real" name for the patch on either
  the Signed-off-by: line, or the From: line (both of which have to
  match).  Please read the kernel file, Documentation/SubmittingPatches
  for how to do this correctly.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging : rtl8188eu : rtw_security.c - Fixed warning: coding style issues - Fixed warning: if statement containing return with an else - Fixed check: coding style issues

2019-08-05 Thread Dan Carpenter


1) Fix the From header.
2) Fix the subject.
3) Add a blank line after the subject.
4) Split the path up into multiple patches that each do one kind of
   change.

On Mon, Aug 05, 2019 at 01:22:56PM +0530, merwintf wrote:
> Signed-off-by: merwintf 
 
Use your real name like for a legal document.

>  static u8 crc32_reverseBit(u8 data)
>  {
> - return (u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) |
> -((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) |
> -((data>>5)&0x02) | ((data>>7)&0x01);
> + return (u8)((data << 7) & 0x80)
> +  | ((data << 5) & 0x40)
> +  | ((data << 3) & 0x20)
> +  | ((data << 1) & 0x10)
> +  | ((data >> 1) & 0x08)
> +  | ((data >> 3) & 0x04)
> +  | ((data >> 5) & 0x02)
> +  | ((data >> 7) & 0x01);


Put the | at the end of the line, not the start.  The cast isn't
required and it kind of messes up the white space so just leave it out
so that we don't have to change this twice.

> + return (u8)((data << 7) & 0x80)
> +  | ((data << 5) & 0x40)
> +  | ((data << 3) & 0x20)
> +  | ((data << 1) & 0x10)
> +  | ((data >> 1) & 0x08)
> +  | ((data >> 3) & 0x04)
> +  | ((data >> 5) & 0x02)
> +  | ((data >> 7) & 0x01);

return ((data << 7) & 0x80) |
   ((data << 5) & 0x40) |

etc.


>  }
>  
>  static void crc32_init(void)
>  {
> - if (bcrc32initialized == 1) {
> - return;
> - } else {
> + if (bcrc32initialized != 1) {

This isn't really an improvement.  Move the declarations outside the
block and do it like this:

int i, j;
u32 c;
u8 *p = (u8 *)&c, *p1;

if (bcrc32initialized == 1)
return;

> @@ -164,7 +172,8 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 
> *pxmitframe)
>   return;
>  
>   if (crypto_ops->set_key(psecuritypriv->dot11DefKey[keyindex].skey,
> - psecuritypriv->dot11DefKeylen[keyindex], NULL, 
> crypto_private) < 0)
> + psecuritypriv->dot11DefKeylen[keyindex],
> + NULL, crypto_private) < 0)
>   goto free_crypto_private;

Introduce an "int ret;" or something.

ret = crypto_ops->set_key();
if (ret < 0)
goto free_crypto_private;




> @@ -201,16 +211,20 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 
> *pxmitframe)
>  
>  int rtw_wep_decrypt(struct adapter  *padapter, u8 *precvframe)
>  {
> - struct  rx_pkt_attrib*prxattrib = &(((struct recv_frame 
> *)precvframe)->attrib);
> + struct  rx_pkt_attrib*prxattrib =
> +   &(((struct recv_frame *)precvframe)->attrib);

This change isn't an improvement.

Anyway, hopefully that gives you some ideas.  But split up the patch.

regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Fix the following checkpatch warnings:

2019-08-05 Thread Dan Carpenter
The subject isn't right and I don't really feel that the change makes
the code more beautiful to look at.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: pi433 line over 80 characters in multiple places

2019-08-05 Thread Dan Carpenter
The subject needs a colon after "pi433:" but also this change isn't
really an improvement so far as readability goes.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: isdn: remove unnecessary parentheses

2019-08-05 Thread Dan Carpenter
This driver is obselete so we're just keeping it around for a couple
kernel releases and then deleting it.  We're not taking cleanups for it.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: pi433 line over 80 characters in multiple places

2019-08-05 Thread Greg Kroah-Hartman
On Mon, Aug 05, 2019 at 05:32:45AM +0530, Giridhar Prasath R wrote:
> Fix the following checkpatch warnings:
> 
> WARNING: line over 80 characters
> FILE: drivers/staging/pi433/pi433_if.h
> 
> Signed-off-by: Giridhar Prasath R 
> ---
>  drivers/staging/pi433/pi433_if.h | 23 ---
>  1 file changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/pi433/pi433_if.h 
> b/drivers/staging/pi433/pi433_if.h
> index 9feb95c431cb..915bd96910c6 100644
> --- a/drivers/staging/pi433/pi433_if.h
> +++ b/drivers/staging/pi433/pi433_if.h
> @@ -117,9 +117,14 @@ struct pi433_rx_cfg {
>  
>   /* packet format */
>   enum option_on_off  enable_sync;
> - enum option_on_off  enable_length_byte;   /* should be used in 
> combination with sync, only */
> - enum address_filtering  enable_address_filtering; /* operational with 
> sync, only */
> - enum option_on_off  enable_crc;   /* only operational, 
> if sync on and fixed length or length byte is used */
> + /* should be used in combination with sync, only */
> + enum option_on_off  enable_length_byte;
> + /* operational with sync, only */
> + enum address_filtering  enable_address_filtering;
> + /* only operational,
> +  * if sync on and fixed length or length byte is used
> +  */
> + enum option_on_off  enable_crc;
>  
>   __u8sync_length;
>   __u8fixed_message_length;
> @@ -132,10 +137,14 @@ struct pi433_rx_cfg {
>  
>  #define PI433_IOC_MAGIC  'r'
>  
> -#define PI433_IOC_RD_TX_CFG  _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, 
> char[sizeof(struct pi433_tx_cfg)])
> -#define PI433_IOC_WR_TX_CFG  _IOW(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR, 
> char[sizeof(struct pi433_tx_cfg)])
> +#define PI433_IOC_RD_TX_CFG  _IOR(PI433_IOC_MAGIC, PI433_TX_CFG_IOCTL_NR,\
> +char[sizeof(struct pi433_tx_cfg)])

Ick, that does not look better :(

We write code for humans first, compilers second.

The original is fine, thanks.

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8192u: Add NULL check post kzalloc

2019-08-05 Thread Greg Kroah-Hartman
On Sun, Aug 04, 2019 at 09:19:05AM +0530, Hariprasad Kelam wrote:
> Collect returns status of kzalloc.
> 
> Signed-off-by: Hariprasad Kelam 
> ---
>  drivers/staging/rtl8192u/r8192U_core.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

Does not apply to my tree :(
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/4] iio: adc: ad7606: Add support for AD7606B ADC

2019-08-05 Thread Jonathan Cameron
On Fri, 2 Aug 2019 13:03:01 +0300
Beniamin Bia  wrote:

> From: Stefan Popa 
> 
> The AD7606B is a 16-bit ADC that supports simultaneous sampling of 8
> channels. It is pin compatible to AD7606, but adds extra modes by
> writing to the register map.
> 
> The AD7606B can be configured to work in software mode by setting all
> oversampling pins to high. This mode is selected by default.
> The oversampling ratio is configured from the OS_MODE register (address
> 0x08) with the addition of OS=128 and OS=256 that were not available in
> hardware mode.
> 
> The device is configured to output data on a single spi channel, but this
> configuration must be done right after restart. That is why the delay was
> removed for devices which doesn't require it.
> 
> Moreover, in software mode, the range gpio has no longer its function.
> Instead, the scale can be configured individually for each channel from
> the RANGE_CH registers (address 0x03 to 0x06). Besides the already
> supported ±10 V and ±5 V ranges, software mode can also accommodate the
> ±2.5 V range.
> 
> Signed-off-by: Stefan Popa 
> Co-developed-by: Beniamin Bia 
> Signed-off-by: Beniamin Bia 

This looks fine to me. I'll pick it up (if no other comments)
when you've tidied up the issues Rob raises for the DT bindings.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7606.c |  13 -
>  drivers/iio/adc/ad7606.h |   4 ++
>  drivers/iio/adc/ad7606_spi.c | 107 +++
>  3 files changed, 122 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index ed2d08437e5d..f5ba94c03a8d 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -410,12 +410,19 @@ static const struct ad7606_chip_info 
> ad7606_chip_info_tbl[] = {
>   .oversampling_avail = ad7606_oversampling_avail,
>   .oversampling_num = ARRAY_SIZE(ad7606_oversampling_avail),
>   },
> + [ID_AD7606B] = {
> + .channels = ad7606_channels,
> + .num_channels = 9,
> + .oversampling_avail = ad7606_oversampling_avail,
> + .oversampling_num = ARRAY_SIZE(ad7606_oversampling_avail),
> + },
>   [ID_AD7616] = {
>   .channels = ad7616_channels,
>   .num_channels = 17,
>   .oversampling_avail = ad7616_oversampling_avail,
>   .oversampling_num = ARRAY_SIZE(ad7616_oversampling_avail),
>   .os_req_reset = true,
> + .init_delay_ms = 15,
>   },
>  };
>  
> @@ -631,8 +638,10 @@ int ad7606_probe(struct device *dev, int irq, void 
> __iomem *base_address,
>   dev_warn(st->dev, "failed to RESET: no RESET GPIO specified\n");
>  
>   /* AD7616 requires al least 15ms to reconfigure after a reset */
> - if (msleep_interruptible(15))
> - return -ERESTARTSYS;
> + if (st->chip_info->init_delay_ms) {
> + if (msleep_interruptible(st->chip_info->init_delay_ms))
> + return -ERESTARTSYS;
> + }
>  
>   st->write_scale = ad7606_write_scale_hw;
>   st->write_os = ad7606_write_os_hw;
> diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
> index eeaaa8b905db..9350ef1f63b5 100644
> --- a/drivers/iio/adc/ad7606.h
> +++ b/drivers/iio/adc/ad7606.h
> @@ -46,6 +46,8 @@
>   *   oversampling ratios.
>   * @oversampling_num number of elements stored in oversampling_avail array
>   * @os_req_reset some devices require a reset to update oversampling
> + * @init_delay_msrequired delay in miliseconds for initialization
> + *   after a restart
>   */
>  struct ad7606_chip_info {
>   const struct iio_chan_spec  *channels;
> @@ -53,6 +55,7 @@ struct ad7606_chip_info {
>   const unsigned int  *oversampling_avail;
>   unsigned intoversampling_num;
>   boolos_req_reset;
> + unsigned long   init_delay_ms;
>  };
>  
>  /**
> @@ -155,6 +158,7 @@ enum ad7606_supported_device_ids {
>   ID_AD7606_8,
>   ID_AD7606_6,
>   ID_AD7606_4,
> + ID_AD7606B,
>   ID_AD7616,
>  };
>  
> diff --git a/drivers/iio/adc/ad7606_spi.c b/drivers/iio/adc/ad7606_spi.c
> index 98ed52b74507..070ee7e31e2c 100644
> --- a/drivers/iio/adc/ad7606_spi.c
> +++ b/drivers/iio/adc/ad7606_spi.c
> @@ -31,6 +31,20 @@
>  /* The range of the channel is stored on 2 bits*/
>  #define AD7616_RANGE_CH_MSK(ch)  (0b11 << (((ch) & 0b11) * 2))
>  #define AD7616_RANGE_CH_MODE(ch, mode)   ((mode) << ch) & 0b11)) * 
> 2))
> +
> +#define AD7606_CONFIGURATION_REGISTER0x02
> +#define AD7606_SINGLE_DOUT   0x0
> +
> +/*
> + * Range for AD7606B channels are stored in registers starting with address 
> 0x3.
> + * Each register stores range for 2 channels(4 bits per channel).
> + */
> +#define AD7606_RANGE_CH_MSK(ch)  (GENMASK(3, 0) << (4 * ((ch) & 
> 0x1)))
> +#defi

Re: [PATCH v2 06/34] drm/i915: convert put_page() to put_user_page*()

2019-08-05 Thread Rodrigo Vivi
On Sun, Aug 04, 2019 at 03:48:47PM -0700, john.hubb...@gmail.com wrote:
> From: John Hubbard 
> 
> For pages that were retained via get_user_pages*(), release those pages
> via the new put_user_page*() routines, instead of via put_page() or
> release_pages().
> 
> This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
> ("mm: introduce put_user_page*(), placeholder versions").
> 
> This is a merge-able version of the fix, because it restricts
> itself to put_user_page() and put_user_pages(), both of which
> have not changed their APIs. Later, i915_gem_userptr_put_pages()
> can be simplified to use put_user_pages_dirty_lock().

Thanks for that.
with this version we won't have any conflict.

Ack for going through mm tree.

> 
> Cc: Jani Nikula 
> Cc: Joonas Lahtinen 
> Cc: Rodrigo Vivi 
> Cc: David Airlie 
> Cc: intel-...@lists.freedesktop.org
> Cc: dri-de...@lists.freedesktop.org
> Signed-off-by: John Hubbard 
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c 
> b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> index 2caa594322bc..76dda2923cf1 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> @@ -527,7 +527,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct 
> *_work)
>   }
>   mutex_unlock(&obj->mm.lock);
>  
> - release_pages(pvec, pinned);
> + put_user_pages(pvec, pinned);
>   kvfree(pvec);
>  
>   i915_gem_object_put(obj);
> @@ -640,7 +640,7 @@ static int i915_gem_userptr_get_pages(struct 
> drm_i915_gem_object *obj)
>   __i915_gem_userptr_set_active(obj, true);
>  
>   if (IS_ERR(pages))
> - release_pages(pvec, pinned);
> + put_user_pages(pvec, pinned);
>   kvfree(pvec);
>  
>   return PTR_ERR_OR_ZERO(pages);
> @@ -675,7 +675,7 @@ i915_gem_userptr_put_pages(struct drm_i915_gem_object 
> *obj,
>   set_page_dirty_lock(page);
>  
>   mark_page_accessed(page);
> - put_page(page);
> + put_user_page(page);
>   }
>   obj->mm.dirty = false;
>  
> -- 
> 2.22.0
> 
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[engineering.redhat.com #494100] Question on submitting patch for a security bug

2019-08-05 Thread Red Hat Product Security
Hello Navid,

On Thu, 18 Jul 2019 01:30:20 GMT, emamd...@umn.edu wrote:
> I've found a null dereference bug in the Linux kernel source code. I was
> wondering should I cc the patch to you as well (along with the
> maintainers)?

No. Please do not cc  on the upstream kernel patches.
It is meant for reporting security issues only.

Going through the patches here

1. Issues in ../staging/ drivers are not considered for CVE, they are not to be
used
in production environment.

2. Many of the patches listed fix NULL pointer dereference when memory
allocation
fails and returns NULL.

3. Do you happen to have reproducers for these issues? Could an unprivileged
user trigger them?

> Also, I was wondering what are the steps to get CVE for the bug (this is
> the first time I am reporting a bug)?

Generally CVE is assigned after confirming that a given issue really is a
security issue. And it may
have impact ranging from information leakage, DoS to privilege escalation or
maybe arbitrary code
execution. Every NULL pointer dereference is not security issue.


Hope it helps. Thank you.
---
Prasad J Pandit / Red Hat Product Security Team

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Lkcamp] [PATCH] staging: isdn: remove unnecessary parentheses

2019-08-05 Thread Helen Koike
Hi,

On Mon, Aug 5, 2019 at 11:51 AM Dan Carpenter  wrote:
>
> This driver is obselete so we're just keeping it around for a couple
> kernel releases and then deleting it.  We're not taking cleanups for it.

I'm sorry, it was me who suggested Thiago to make this change
as his first contribution, I didn't see the TODO file.

Thiago, it would be great if you could send a patch to another staging driver
to get starting and to learn how the kernel development cycle works.
Feel free to ping me or the lkcamp group if you want some pointers/guidance.

Thanks both for your contribution.
Helen

>
> regards,
> dan carpenter
>
>
> ___
> Lkcamp mailing list
> lkc...@lists.libreplanetbr.org
> https://lists.libreplanetbr.org/mailman/listinfo/lkcamp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [Lkcamp] [PATCH] isdn: hysdn: fix code style error from checkpatch

2019-08-05 Thread Helen Koike
Hi,

On Fri, Aug 2, 2019 at 6:55 PM Stephen Hemminger
 wrote:
>
> On Fri,  2 Aug 2019 19:50:17 +
> Ricardo Bruno Lopes da Silva  wrote:
>
> > Fix error bellow from checkpatch.
> >
> > WARNING: Block comments use * on subsequent lines
> > +/***
> > +
> >
> > Signed-off-by: Ricardo Bruno Lopes da Silva 
>
> Read the TODO, these drivers are scheduled for removal, so changes
> are not helpful at this time.

I'm sorry, it was me who suggested Ricardo to make this change
as his first contribution, I didn't see the TODO file.

Ricardo, it would be great if you could send a patch to another staging driver
to get starting and to learn how the kernel development cycle works.
Feel free to ping me or the lkcamp group if you want some pointers/guidance.

Thanks both for your contribution.
Helen

>
> ___
> Lkcamp mailing list
> lkc...@lists.libreplanetbr.org
> https://lists.libreplanetbr.org/mailman/listinfo/lkcamp
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/22] media: imx7-mipi-csis: Create media links in bound notifier

2019-08-05 Thread Steve Longerbeam
Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the mipi csi-2 receiver sink pad.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 25 ++
 1 file changed, 25 insertions(+)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c 
b/drivers/staging/media/imx/imx7-mipi-csis.c
index f71d9183cad2..e03b2317a1ac 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -259,6 +259,12 @@ struct csi_state {
bool sink_linked;
 };
 
+static inline struct csi_state *
+notifier_to_csis_state(struct v4l2_async_notifier *n)
+{
+   return container_of(n, struct csi_state, notifier);
+}
+
 struct csis_pix_format {
unsigned int pix_width_alignment;
u32 code;
@@ -863,6 +869,23 @@ static int mipi_csis_parse_endpoint(struct device *dev,
return 0;
 }
 
+static int mipi_csis_notify_bound(struct v4l2_async_notifier *notifier,
+ struct v4l2_subdev *sd,
+ struct v4l2_async_subdev *asd)
+{
+   struct csi_state *state = notifier_to_csis_state(notifier);
+   struct media_pad *sink = &state->mipi_sd.entity.pads[CSIS_PAD_SINK];
+
+   return media_create_fwnode_pad_links(sink,
+dev_fwnode(state->mipi_sd.dev),
+&sd->entity,
+dev_fwnode(sd->dev), 0);
+}
+
+static const struct v4l2_async_notifier_operations mipi_csis_notify_ops = {
+   .bound = mipi_csis_notify_bound,
+};
+
 static int mipi_csis_subdev_init(struct v4l2_subdev *mipi_sd,
 struct platform_device *pdev,
 const struct v4l2_subdev_ops *ops)
@@ -895,6 +918,8 @@ static int mipi_csis_subdev_init(struct v4l2_subdev 
*mipi_sd,
 
v4l2_async_notifier_init(&state->notifier);
 
+   state->notifier.ops = &mipi_csis_notify_ops;
+
ret = v4l2_async_register_fwnode_subdev(mipi_sd, &state->notifier,
sizeof(struct 
v4l2_async_subdev),
&sink_port, 1,
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/22] media: imx: csi: Embed notifier in struct csi_priv

2019-08-05 Thread Steve Longerbeam
Embed the notifier in 'struct csi_priv', instead of dynamically allocating
it, to make it possible to retrieve csi_priv in a notifier callback op.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 25 +--
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index e193f66fa230..b39d79e63ac2 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -58,6 +58,8 @@ struct csi_priv {
struct ipu_soc *ipu;
struct v4l2_subdev sd;
struct media_pad pad[CSI_NUM_PADS];
+   struct v4l2_async_notifier notifier;
+
/* the video device at IDMAC output pad */
struct imx_media_video_dev *vdev;
struct imx_media_fim *fim;
@@ -1895,31 +1897,28 @@ static int imx_csi_parse_endpoint(struct device *dev,
 
 static int imx_csi_async_register(struct csi_priv *priv)
 {
-   struct v4l2_async_notifier *notifier;
struct fwnode_handle *fwnode;
unsigned int port;
int ret;
 
-   notifier = kzalloc(sizeof(*notifier), GFP_KERNEL);
-   if (!notifier)
-   return -ENOMEM;
-
-   v4l2_async_notifier_init(notifier);
+   v4l2_async_notifier_init(&priv->notifier);
 
fwnode = dev_fwnode(priv->dev);
 
/* get this CSI's port id */
ret = fwnode_property_read_u32(fwnode, "reg", &port);
if (ret < 0)
-   goto out_free;
+   return ret;
 
ret = v4l2_async_notifier_parse_fwnode_endpoints_by_port(
-   priv->dev->parent, notifier, sizeof(struct v4l2_async_subdev),
+   priv->dev->parent, &priv->notifier,
+   sizeof(struct v4l2_async_subdev),
port, imx_csi_parse_endpoint);
if (ret < 0)
goto out_cleanup;
 
-   ret = v4l2_async_subdev_notifier_register(&priv->sd, notifier);
+   ret = v4l2_async_subdev_notifier_register(&priv->sd,
+ &priv->notifier);
if (ret < 0)
goto out_cleanup;
 
@@ -1927,16 +1926,12 @@ static int imx_csi_async_register(struct csi_priv *priv)
if (ret < 0)
goto out_unregister;
 
-   priv->sd.subdev_notifier = notifier;
-
return 0;
 
 out_unregister:
-   v4l2_async_notifier_unregister(notifier);
+   v4l2_async_notifier_unregister(&priv->notifier);
 out_cleanup:
-   v4l2_async_notifier_cleanup(notifier);
-out_free:
-   kfree(notifier);
+   v4l2_async_notifier_cleanup(&priv->notifier);
 
return ret;
 }
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/22] media: imx: csi: Create media links in bound notifier

2019-08-05 Thread Steve Longerbeam
Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the CSI sink pad.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index b39d79e63ac2..37b10cbf3c1a 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -120,6 +120,11 @@ static inline struct csi_priv *sd_to_dev(struct 
v4l2_subdev *sdev)
return container_of(sdev, struct csi_priv, sd);
 }
 
+static inline struct csi_priv *notifier_to_dev(struct v4l2_async_notifier *n)
+{
+   return container_of(n, struct csi_priv, notifier);
+}
+
 static inline bool is_parallel_bus(struct v4l2_fwnode_endpoint *ep)
 {
return ep->bus_type != V4L2_MBUS_CSI2_DPHY;
@@ -1895,6 +1900,23 @@ static int imx_csi_parse_endpoint(struct device *dev,
return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN;
 }
 
+static int imx_csi_notify_bound(struct v4l2_async_notifier *notifier,
+   struct v4l2_subdev *sd,
+   struct v4l2_async_subdev *asd)
+{
+   struct csi_priv *priv = notifier_to_dev(notifier);
+   struct media_pad *sink = &priv->sd.entity.pads[CSI_SINK_PAD];
+
+   return media_create_fwnode_pad_links(sink,
+dev_fwnode(priv->dev->parent),
+&sd->entity,
+dev_fwnode(sd->dev), 0);
+}
+
+static const struct v4l2_async_notifier_operations csi_notify_ops = {
+   .bound = imx_csi_notify_bound,
+};
+
 static int imx_csi_async_register(struct csi_priv *priv)
 {
struct fwnode_handle *fwnode;
@@ -1903,6 +1925,8 @@ static int imx_csi_async_register(struct csi_priv *priv)
 
v4l2_async_notifier_init(&priv->notifier);
 
+   priv->notifier.ops = &csi_notify_ops;
+
fwnode = dev_fwnode(priv->dev);
 
/* get this CSI's port id */
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/22] media: Move v4l2_fwnode_parse_link from v4l2 to driver base

2019-08-05 Thread Steve Longerbeam
There is nothing v4l2-specific about v4l2_fwnode_{parse|put}_link().
Make these functions more generally available by moving them to driver
base, with the appropriate name changes to the functions and struct.

In the process embed a 'struct fwnode_endpoint' in 'struct fwnode_link'
for both sides of the link, and make use of fwnode_graph_parse_endpoint()
to fully parse both endpoints. Rename members local_node and
remote_node to more descriptive local_port_parent and
remote_port_parent.

Signed-off-by: Steve Longerbeam 
---
 drivers/base/property.c | 63 +++
 drivers/media/platform/xilinx/xilinx-vipp.c | 69 +++--
 drivers/media/v4l2-core/v4l2-fwnode.c   | 39 
 drivers/staging/media/imx/imx-media-of.c| 49 +++
 include/linux/fwnode.h  | 14 +
 include/linux/property.h|  5 ++
 include/media/v4l2-fwnode.h | 44 -
 7 files changed, 141 insertions(+), 142 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 81bd01ed4042..dd82cd150d84 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1100,6 +1100,69 @@ int fwnode_graph_parse_endpoint(const struct 
fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
 
+/**
+ * fwnode_graph_parse_link() - parse a link between two endpoints
+ * @local_endpoint: the endpoint's fwnode at the local end of the link
+ * @link: pointer to the fwnode link data structure
+ *
+ * Fill the link structure with the parsed local and remote endpoint info
+ * and the local and remote port parent nodes.
+ *
+ * A reference is taken to both the local and remote port parent nodes,
+ * the caller must use fwnode_graph_put_link() to drop the references
+ * when done with the link.
+ *
+ * Return: 0 on success, or -ENOLINK if the remote endpoint fwnode
+ * can't be found.
+ */
+int fwnode_graph_parse_link(struct fwnode_handle *local_endpoint,
+   struct fwnode_link *link)
+{
+   struct fwnode_handle *remote_endpoint;
+   int ret;
+
+   memset(link, 0, sizeof(*link));
+
+   ret = fwnode_graph_parse_endpoint(local_endpoint, &link->local);
+   if (ret < 0)
+   return ret;
+
+   remote_endpoint = fwnode_graph_get_remote_endpoint(local_endpoint);
+   if (!remote_endpoint)
+   return -ENOLINK;
+
+   ret = fwnode_graph_parse_endpoint(remote_endpoint, &link->remote);
+   if (ret < 0) {
+   fwnode_handle_put(remote_endpoint);
+   return ret;
+   }
+
+   link->local_port_parent =
+   fwnode_graph_get_port_parent(local_endpoint);
+   link->remote_port_parent =
+   fwnode_graph_get_port_parent(remote_endpoint);
+
+   fwnode_handle_put(remote_endpoint);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(fwnode_graph_parse_link);
+
+/**
+ * fwnode_graph_put_link() - drop references to port parent nodes in a link
+ * @link: pointer to the fwnode link data structure
+ *
+ * Drop references to the local and remote port parent nodes in the link.
+ * This function must be called on every link parsed with
+ * fwnode_graph_parse_link().
+ */
+void fwnode_graph_put_link(struct fwnode_link *link)
+{
+   fwnode_handle_put(link->local_port_parent);
+   fwnode_handle_put(link->remote_port_parent);
+}
+EXPORT_SYMBOL_GPL(fwnode_graph_put_link);
+
 const void *device_get_match_data(struct device *dev)
 {
return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev);
diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c 
b/drivers/media/platform/xilinx/xilinx-vipp.c
index cc2856efea59..9c0dfc694478 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -74,7 +74,7 @@ static int xvip_graph_build_one(struct xvip_composite_device 
*xdev,
struct media_pad *local_pad;
struct media_pad *remote_pad;
struct xvip_graph_entity *ent;
-   struct v4l2_fwnode_link link;
+   struct fwnode_link link;
struct fwnode_handle *ep = NULL;
int ret = 0;
 
@@ -89,7 +89,7 @@ static int xvip_graph_build_one(struct xvip_composite_device 
*xdev,
 
dev_dbg(xdev->dev, "processing endpoint %p\n", ep);
 
-   ret = v4l2_fwnode_parse_link(ep, &link);
+   ret = fwnode_graph_parse_link(ep, &link);
if (ret < 0) {
dev_err(xdev->dev, "failed to parse link for %p\n",
ep);
@@ -99,54 +99,55 @@ static int xvip_graph_build_one(struct 
xvip_composite_device *xdev,
/* Skip sink ports, they will be processed from the other end of
 * the link.
 */
-   if (link.local_port >= local->num_pads) {
+   if (link.local.port >= local->num_pads) {
dev_err(xdev->dev, "invalid port number %u for %p\n",
-  

[PATCH 21/22] media: imx: Use media_create_fwnode_links for external links

2019-08-05 Thread Steve Longerbeam
The entities external to the i.MX6 IPU and i.MX7 now create the links
to their fwnode-endpoint connected entities in their notifier bound
callbacks.

This should mean that there is no longer a need for the imx-media driver
to create these external fwnode-endpoint based links. But the v4l2-async
framework does not allow multiple subdevice notifiers to contain a
duplicate subdevice in their asd_list. Only the first subdev notifier that
discovers and adds that one subdevice to its asd_list will receive a bound
callback for it. Other subdevices that also have firmware endpoint
connections to this duplicate subdevice will not have it in their asd_list,
and thus will never receive a bound callback for it.

Until there is a solution to that problem, imx_media_create_links() is
still needed to create media links for subdevices that never received a
bound callback.

But media_create_fwnode_links() can now be used to do that work, so
imx_media_create_of_links() and imx_media_create_csi_of_links() are
removed.

Signed-off-by: Steve Longerbeam 
---
 .../staging/media/imx/imx-media-dev-common.c  |  49 
 drivers/staging/media/imx/imx-media-of.c  | 113 --
 drivers/staging/media/imx/imx-media.h |   4 -
 3 files changed, 27 insertions(+), 139 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-dev-common.c 
b/drivers/staging/media/imx/imx-media-dev-common.c
index 66b505f7e8df..4dbe983af030 100644
--- a/drivers/staging/media/imx/imx-media-dev-common.c
+++ b/drivers/staging/media/imx/imx-media-dev-common.c
@@ -36,31 +36,36 @@ static int imx_media_subdev_bound(struct 
v4l2_async_notifier *notifier,
 static int imx_media_create_links(struct v4l2_async_notifier *notifier)
 {
struct imx_media_dev *imxmd = notifier2dev(notifier);
-   struct v4l2_subdev *sd;
+   struct fwnode_handle *sda_fwnode, *sdb_fwnode;
+   struct v4l2_subdev *sda, *sdb;
+
+   list_for_each_entry(sda, &imxmd->v4l2_dev.subdevs, list) {
+   /* links have already been created for the IPU subdevs */
+   if (is_ipu_internal_subdev(sda))
+   continue;
+
+   sda_fwnode = (sda->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) ?
+   dev_fwnode(sda->dev->parent) :
+   dev_fwnode(sda->dev);
+
+   list_for_each_entry(sdb, &imxmd->v4l2_dev.subdevs, list) {
+   if (sda == sdb)
+   continue;
+   if (is_ipu_internal_subdev(sdb))
+   continue;
+
+   sdb_fwnode = (sdb->grp_id & IMX_MEDIA_GRP_ID_IPU_CSI) ?
+   dev_fwnode(sdb->dev->parent) :
+   dev_fwnode(sdb->dev);
 
-   list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
-   switch (sd->grp_id) {
-   case IMX_MEDIA_GRP_ID_IPU_VDIC:
-   case IMX_MEDIA_GRP_ID_IPU_IC_PRP:
-   case IMX_MEDIA_GRP_ID_IPU_IC_PRPENC:
-   case IMX_MEDIA_GRP_ID_IPU_IC_PRPVF:
-   /*
-* links have already been created for the
-* sync-registered subdevs.
-*/
-   break;
-   case IMX_MEDIA_GRP_ID_IPU_CSI0:
-   case IMX_MEDIA_GRP_ID_IPU_CSI1:
-   case IMX_MEDIA_GRP_ID_CSI:
-   imx_media_create_csi_of_links(imxmd, sd);
-   break;
-   default:
/*
-* if this subdev has fwnode links, create media
-* links for them.
+* if there are fwnode endpoint connections between
+* these subdevs, create media links for them.
 */
-   imx_media_create_of_links(imxmd, sd);
-   break;
+   __media_create_fwnode_links(&sda->entity,
+   sda_fwnode,
+   &sdb->entity,
+   sdb_fwnode, 0);
}
}
 
diff --git a/drivers/staging/media/imx/imx-media-of.c 
b/drivers/staging/media/imx/imx-media-of.c
index 736c954a8ff5..82e13e972e23 100644
--- a/drivers/staging/media/imx/imx-media-of.c
+++ b/drivers/staging/media/imx/imx-media-of.c
@@ -74,116 +74,3 @@ int imx_media_add_of_subdevs(struct imx_media_dev *imxmd,
return ret;
 }
 EXPORT_SYMBOL_GPL(imx_media_add_of_subdevs);
-
-/*
- * Create a single media link to/from sd using a fwnode link.
- *
- * NOTE: this function assumes an OF port node is equivalent to
- * a media pad (port id equal to media pad index), and that an
- * OF endpoint node is equivalent to a media link.
- */
-static int create_of_link(struct imx_media_dev *imxmd,
- struct v4l2_subdev *sd,

[PATCH 13/22] media: imx: mipi csi-2: Create media links in bound notifier

2019-08-05 Thread Steve Longerbeam
Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the mipi csi-2 receiver sink pad.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx6-mipi-csi2.c | 24 ++
 1 file changed, 24 insertions(+)

diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c 
b/drivers/staging/media/imx/imx6-mipi-csi2.c
index 408ee2765e77..5b2258156781 100644
--- a/drivers/staging/media/imx/imx6-mipi-csi2.c
+++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
@@ -91,6 +91,11 @@ static inline struct csi2_dev *sd_to_dev(struct v4l2_subdev 
*sdev)
return container_of(sdev, struct csi2_dev, sd);
 }
 
+static inline struct csi2_dev *notifier_to_dev(struct v4l2_async_notifier *n)
+{
+   return container_of(n, struct csi2_dev, notifier);
+}
+
 /*
  * The required sequence of MIPI CSI-2 startup as specified in the i.MX6
  * reference manual is as follows:
@@ -573,6 +578,23 @@ static int csi2_parse_endpoint(struct device *dev,
return 0;
 }
 
+static int csi2_notify_bound(struct v4l2_async_notifier *notifier,
+struct v4l2_subdev *sd,
+struct v4l2_async_subdev *asd)
+{
+   struct csi2_dev *csi2 = notifier_to_dev(notifier);
+   struct media_pad *sink = &csi2->sd.entity.pads[CSI2_SINK_PAD];
+
+   return media_create_fwnode_pad_links(sink,
+dev_fwnode(csi2->dev),
+&sd->entity,
+dev_fwnode(sd->dev), 0);
+}
+
+static const struct v4l2_async_notifier_operations csi2_notify_ops = {
+   .bound = csi2_notify_bound,
+};
+
 static int csi2_probe(struct platform_device *pdev)
 {
unsigned int sink_port = 0;
@@ -646,6 +668,8 @@ static int csi2_probe(struct platform_device *pdev)
 
v4l2_async_notifier_init(&csi2->notifier);
 
+   csi2->notifier.ops = &csi2_notify_ops;
+
ret = v4l2_async_register_fwnode_subdev(
&csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev),
&sink_port, 1, csi2_parse_endpoint);
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/22] media: imx: csi: Lookup endpoint fwnode with media_entity_get_fwnode_pad

2019-08-05 Thread Steve Longerbeam
Fix the 1:1 port-id:pad-index assumption for the upstream subdevice
connected to a CSI via one of the subdevice's pads, by searching the
upstream subdevice's endpoints for one that maps to the pad's index,
using media_entity_get_fwnode_pad(). This is carried out by a new
reverse mapping function imx_media_get_pad_fwnode().

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c   | 22 --
 drivers/staging/media/imx/imx-media-utils.c | 33 +
 drivers/staging/media/imx/imx-media.h   |  1 +
 drivers/staging/media/imx/imx7-media-csi.c  | 25 +---
 4 files changed, 47 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 37b10cbf3c1a..38e70082ff2d 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -164,7 +164,7 @@ static inline bool requires_passthrough(struct 
v4l2_fwnode_endpoint *ep,
 static int csi_get_upstream_endpoint(struct csi_priv *priv,
 struct v4l2_fwnode_endpoint *ep)
 {
-   struct device_node *endpoint, *port;
+   struct fwnode_handle *endpoint;
struct media_entity *src;
struct v4l2_subdev *sd;
struct media_pad *pad;
@@ -203,23 +203,13 @@ static int csi_get_upstream_endpoint(struct csi_priv 
*priv,
if (!pad)
return -ENODEV;
 
-   sd = media_entity_to_v4l2_subdev(pad->entity);
+   endpoint = imx_media_get_pad_fwnode(pad);
+   if (IS_ERR(endpoint))
+   return PTR_ERR(endpoint);
 
-   /*
-* NOTE: this assumes an OF-graph port id is the same as a
-* media pad index.
-*/
-   port = of_graph_get_port_by_id(sd->dev->of_node, pad->index);
-   if (!port)
-   return -ENODEV;
-
-   endpoint = of_get_next_child(port, NULL);
-   of_node_put(port);
-   if (!endpoint)
-   return -ENODEV;
+   v4l2_fwnode_endpoint_parse(endpoint, ep);
 
-   v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), ep);
-   of_node_put(endpoint);
+   fwnode_handle_put(endpoint);
 
return 0;
 }
diff --git a/drivers/staging/media/imx/imx-media-utils.c 
b/drivers/staging/media/imx/imx-media-utils.c
index 4cc6a7462ae2..2e4f27c214c4 100644
--- a/drivers/staging/media/imx/imx-media-utils.c
+++ b/drivers/staging/media/imx/imx-media-utils.c
@@ -908,6 +908,39 @@ imx_media_pipeline_video_device(struct media_entity 
*start_entity,
 }
 EXPORT_SYMBOL_GPL(imx_media_pipeline_video_device);
 
+/*
+ * Find a fwnode endpoint that maps to the given subdevice's pad.
+ * If there are multiple endpoints that map to the pad, only the
+ * first endpoint encountered is returned.
+ *
+ * On success the refcount of the returned fwnode endpoint is
+ * incremented.
+ */
+struct fwnode_handle *imx_media_get_pad_fwnode(struct media_pad *pad)
+{
+   struct fwnode_handle *endpoint;
+   struct v4l2_subdev *sd;
+
+   if (!is_media_entity_v4l2_subdev(pad->entity))
+   return ERR_PTR(-ENODEV);
+
+   sd = media_entity_to_v4l2_subdev(pad->entity);
+
+   fwnode_graph_for_each_endpoint(dev_fwnode(sd->dev), endpoint) {
+   int pad_idx = media_entity_get_fwnode_pad(&sd->entity,
+ endpoint,
+ pad->flags);
+   if (pad_idx < 0)
+   continue;
+
+   if (pad_idx == pad->index)
+   return endpoint;
+   }
+
+   return ERR_PTR(-ENODEV);
+}
+EXPORT_SYMBOL_GPL(imx_media_get_pad_fwnode);
+
 /*
  * Turn current pipeline streaming on/off starting from entity.
  */
diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index 4d124a86b358..d75b3c80101a 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -195,6 +195,7 @@ imx_media_pipeline_subdev(struct media_entity 
*start_entity, u32 grp_id,
 struct video_device *
 imx_media_pipeline_video_device(struct media_entity *start_entity,
enum v4l2_buf_type buftype, bool upstream);
+struct fwnode_handle *imx_media_get_pad_fwnode(struct media_pad *pad);
 
 struct imx_media_dma_buf {
void  *virt;
diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
index f71ac485f780..50826e637cb5 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -438,9 +438,8 @@ static int imx7_csi_get_upstream_endpoint(struct imx7_csi 
*csi,
  struct v4l2_fwnode_endpoint *ep,
  bool skip_mux)
 {
-   struct device_node *endpoint, *port;
+   struct fwnode_handle *endpoint;
struct media_entity *src;
-   struct v4l2_sub

[PATCH 11/22] media: v4l2-fwnode: Pass notifier to v4l2_async_register_fwnode_subdev()

2019-08-05 Thread Steve Longerbeam
Instead of allocating a notifier in v4l2_async_register_fwnode_subdev(),
have the caller provide one. This allows the caller to implement
notifier ops (bind, unbind).

The caller is now responsible for first initializing its notifier with a
call to v4l2_async_notifier_init().

Signed-off-by: Steve Longerbeam 
---
 drivers/media/platform/video-mux.c |  6 +-
 drivers/media/v4l2-core/v4l2-fwnode.c  | 11 +--
 drivers/staging/media/imx/imx6-mipi-csi2.c |  5 -
 drivers/staging/media/imx/imx7-media-csi.c |  5 -
 drivers/staging/media/imx/imx7-mipi-csis.c |  5 -
 include/media/v4l2-fwnode.h| 12 
 6 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/video-mux.c 
b/drivers/media/platform/video-mux.c
index ddd0e338f9e4..ca1cef783646 100644
--- a/drivers/media/platform/video-mux.c
+++ b/drivers/media/platform/video-mux.c
@@ -21,6 +21,7 @@
 
 struct video_mux {
struct v4l2_subdev subdev;
+   struct v4l2_async_notifier notifier;
struct media_pad *pads;
struct v4l2_mbus_framefmt *format_mbus;
struct mux_control *mux;
@@ -354,8 +355,11 @@ static int video_mux_async_register(struct video_mux *vmux,
for (i = 0; i < num_input_pads; i++)
ports[i] = i;
 
+   v4l2_async_notifier_init(&vmux->notifier);
+
ret = v4l2_async_register_fwnode_subdev(
-   &vmux->subdev, sizeof(struct v4l2_async_subdev),
+   &vmux->subdev, &vmux->notifier,
+   sizeof(struct v4l2_async_subdev),
ports, num_input_pads, video_mux_parse_endpoint);
 
kfree(ports);
diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 5d4ce4aa3fdc..8f5b3fdea061 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -1124,12 +1124,12 @@ int v4l2_async_register_subdev_sensor_common(struct 
v4l2_subdev *sd)
 EXPORT_SYMBOL_GPL(v4l2_async_register_subdev_sensor_common);
 
 int v4l2_async_register_fwnode_subdev(struct v4l2_subdev *sd,
+ struct v4l2_async_notifier *notifier,
  size_t asd_struct_size,
  unsigned int *ports,
  unsigned int num_ports,
  parse_endpoint_func parse_endpoint)
 {
-   struct v4l2_async_notifier *notifier;
struct device *dev = sd->dev;
struct fwnode_handle *fwnode;
int ret;
@@ -1141,12 +1141,6 @@ int v4l2_async_register_fwnode_subdev(struct v4l2_subdev 
*sd,
if (!fwnode_device_is_available(fwnode))
return -ENODEV;
 
-   notifier = kzalloc(sizeof(*notifier), GFP_KERNEL);
-   if (!notifier)
-   return -ENOMEM;
-
-   v4l2_async_notifier_init(notifier);
-
if (!ports) {
ret = v4l2_async_notifier_parse_fwnode_endpoints(dev, notifier,
 
asd_struct_size,
@@ -1171,15 +1165,12 @@ int v4l2_async_register_fwnode_subdev(struct 
v4l2_subdev *sd,
if (ret < 0)
goto out_unregister;
 
-   sd->subdev_notifier = notifier;
-
return 0;
 
 out_unregister:
v4l2_async_notifier_unregister(notifier);
 out_cleanup:
v4l2_async_notifier_cleanup(notifier);
-   kfree(notifier);
 
return ret;
 }
diff --git a/drivers/staging/media/imx/imx6-mipi-csi2.c 
b/drivers/staging/media/imx/imx6-mipi-csi2.c
index f29e28df36ed..408ee2765e77 100644
--- a/drivers/staging/media/imx/imx6-mipi-csi2.c
+++ b/drivers/staging/media/imx/imx6-mipi-csi2.c
@@ -35,6 +35,7 @@
 struct csi2_dev {
struct device  *dev;
struct v4l2_subdev  sd;
+   struct v4l2_async_notifier notifier;
struct media_pad   pad[CSI2_NUM_PADS];
struct clk *dphy_clk;
struct clk *pllref_clk;
@@ -643,8 +644,10 @@ static int csi2_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, &csi2->sd);
 
+   v4l2_async_notifier_init(&csi2->notifier);
+
ret = v4l2_async_register_fwnode_subdev(
-   &csi2->sd, sizeof(struct v4l2_async_subdev),
+   &csi2->sd, &csi2->notifier, sizeof(struct v4l2_async_subdev),
&sink_port, 1, csi2_parse_endpoint);
if (ret)
goto dphy_off;
diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
index 500b4c08d967..a1c96c52a606 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -155,6 +155,7 @@
 struct imx7_csi {
struct device *dev;
struct v4l2_subdev sd;
+   struct v4l2_async_notifier notifier;
struct imx_media_video_dev *vdev;
struct imx_media_dev *imxmd;
struct media_pad pad[IMX7_CSI_PADS_NUM];
@@ -1

[PATCH 16/22] media: imx: csi: Implement get_fwnode_pad

2019-08-05 Thread Steve Longerbeam
The CSI does not have a 1:1 relationship between fwnode port numbers and
pad indexes. In fact the CSI fwnode device is itself a port which is the
sink, containing only a single fwnode endpoint. Implement media_entity
operation get_fwnode_pad to first verify the given endpoint is the CSI's
sink endpoint, and if so return the CSI sink pad index.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media-csi.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 367e39f5b382..e193f66fa230 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1824,9 +1824,32 @@ static void csi_unregistered(struct v4l2_subdev *sd)
ipu_csi_put(priv->csi);
 }
 
+/*
+ * The CSI has only one fwnode endpoint, at the sink pad. Verify the
+ * endpoint belongs to us, and return CSI_SINK_PAD.
+ */
+static int csi_get_fwnode_pad(struct media_entity *entity,
+ struct fwnode_endpoint *endpoint)
+{
+   struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
+   struct csi_priv *priv = v4l2_get_subdevdata(sd);
+   struct fwnode_handle *csi_port = dev_fwnode(priv->dev);
+   struct fwnode_handle *csi_ep;
+   int ret;
+
+   csi_ep = fwnode_get_next_child_node(csi_port, NULL);
+
+   ret = endpoint->local_fwnode == csi_ep ? CSI_SINK_PAD : -ENXIO;
+
+   fwnode_handle_put(csi_ep);
+
+   return ret;
+}
+
 static const struct media_entity_operations csi_entity_ops = {
.link_setup = csi_link_setup,
.link_validate = v4l2_subdev_link_validate,
+   .get_fwnode_pad = csi_get_fwnode_pad,
 };
 
 static const struct v4l2_subdev_core_ops csi_core_ops = {
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 22/22] media: imx: TODO: Remove issues regarding media link creation

2019-08-05 Thread Steve Longerbeam
Remove the TODO items regarding media link creation, these issues are
resolved after exporting media link creation to individual entity bound
callbacks and the use of media_create_fwnode_links(),
media_create_fwnode_pad_links(), and media_entity_get_fwnode_pad().

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/TODO | 29 -
 1 file changed, 29 deletions(-)

diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO
index 6f29b5ca5324..a371cdedcdb0 100644
--- a/drivers/staging/media/imx/TODO
+++ b/drivers/staging/media/imx/TODO
@@ -17,35 +17,6 @@
   decided whether this feature is useful enough to make it generally
   available by exporting to v4l2-core.
 
-- After all async subdevices have been bound, v4l2_fwnode_parse_link()
-  is used to form the media links between the devices discovered in
-  the OF graph.
-
-  While this approach allows support for arbitrary OF graphs, there
-  are some assumptions for this to work:
-
-  1. If a port owned by a device in the graph has endpoint nodes, the
- port is treated as a media pad.
-
- This presents problems for devices that don't make this port = pad
- assumption. Examples are SMIAPP compatible cameras which define only
- a single output port node, but which define multiple pads owned
- by multiple subdevices (pixel-array, binner, scaler). Or video
- decoders (entity function MEDIA_ENT_F_ATV_DECODER), which also define
- only a single output port node, but define multiple pads for video,
- VBI, and audio out.
-
- A workaround at present is to set the port reg properties to
- correspond to the media pad index that the port represents. A
- possible long-term solution is to implement a subdev API that
- maps a port id to a media pad index.
-
-  2. Every endpoint of a port owned by a device in the graph is treated
- as a media link.
-
- Which means a port must not contain mixed-use endpoints, they
- must all refer to media links between V4L2 subdevices.
-
 - i.MX7: all of the above, since it uses the imx media core
 
 - i.MX7: use Frame Interval Monitor
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/22] media: imx7-media-csi: Create media links in bound notifier

2019-08-05 Thread Steve Longerbeam
Implement a notifier bound op to register media links from the remote
sub-device's source pad(s) to the CSI sink pad.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx7-media-csi.c | 24 ++
 1 file changed, 24 insertions(+)

diff --git a/drivers/staging/media/imx/imx7-media-csi.c 
b/drivers/staging/media/imx/imx7-media-csi.c
index a1c96c52a606..f71ac485f780 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -196,6 +196,11 @@ struct imx7_csi {
struct completion last_eof_completion;
 };
 
+static inline struct imx7_csi *notifier_to_dev(struct v4l2_async_notifier *n)
+{
+   return container_of(n, struct imx7_csi, notifier);
+}
+
 static u32 imx7_csi_reg_read(struct imx7_csi *csi, unsigned int offset)
 {
return readl(csi->regbase + offset);
@@ -1173,6 +1178,23 @@ static int imx7_csi_parse_endpoint(struct device *dev,
return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL;
 }
 
+static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier,
+struct v4l2_subdev *sd,
+struct v4l2_async_subdev *asd)
+{
+   struct imx7_csi *csi = notifier_to_dev(notifier);
+   struct media_pad *sink = &csi->sd.entity.pads[IMX7_CSI_PAD_SINK];
+
+   return media_create_fwnode_pad_links(sink,
+dev_fwnode(csi->sd.dev),
+&sd->entity,
+dev_fwnode(sd->dev), 0);
+}
+
+static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = {
+   .bound = imx7_csi_notify_bound,
+};
+
 static int imx7_csi_probe(struct platform_device *pdev)
 {
struct device *dev = &pdev->dev;
@@ -1253,6 +1275,8 @@ static int imx7_csi_probe(struct platform_device *pdev)
 
v4l2_async_notifier_init(&csi->notifier);
 
+   csi->notifier.ops = &imx7_csi_notify_ops;
+
ret = v4l2_async_register_fwnode_subdev(&csi->sd, &csi->notifier,
sizeof(struct 
v4l2_async_subdev),
NULL, 0,
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 20/22] media: imx: Add is_ipu_internal_subdev()

2019-08-05 Thread Steve Longerbeam
Add a convenience inline function that returns true if the given
subdevice is one of the i.MX5/6 IPU-internal subdevices.

Signed-off-by: Steve Longerbeam 
---
 drivers/staging/media/imx/imx-media.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/staging/media/imx/imx-media.h 
b/drivers/staging/media/imx/imx-media.h
index d75b3c80101a..c42a2cafb8fb 100644
--- a/drivers/staging/media/imx/imx-media.h
+++ b/drivers/staging/media/imx/imx-media.h
@@ -282,4 +282,12 @@ void imx_media_capture_device_error(struct 
imx_media_video_dev *vdev);
 #define IMX_MEDIA_GRP_ID_IPU_IC_PRPENC BIT(14)
 #define IMX_MEDIA_GRP_ID_IPU_IC_PRPVF  BIT(15)
 
+static inline bool is_ipu_internal_subdev(struct v4l2_subdev *sd)
+{
+   return sd->grp_id == IMX_MEDIA_GRP_ID_IPU_VDIC ||
+   sd->grp_id == IMX_MEDIA_GRP_ID_IPU_IC_PRP ||
+   sd->grp_id == IMX_MEDIA_GRP_ID_IPU_IC_PRPENC ||
+   sd->grp_id == IMX_MEDIA_GRP_ID_IPU_IC_PRPVF;
+}
+
 #endif
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] rtl8712: rtl871x_ioctl_linux.c: fix unnecessary typecast

2019-08-05 Thread Jose Carlos Cazarin Filho
Fix checkpath warning:
WARNING: Unnecessary typecast of c90 int constant

Signed-off-by: Jose Carlos Cazarin Filho 
---
 Hello all!
 This is my first commit to the Linux Kernel, I'm doing this to learn and be 
able
 to contribute more in the future
 Peace all! 
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c 
b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 944336e0d..da371072e 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -665,8 +665,8 @@ static int r8711_wx_set_freq(struct net_device *dev,
 
 /* If setting by frequency, convert to a channel */
if ((fwrq->e == 1) &&
- (fwrq->m >= (int) 2.412e8) &&
- (fwrq->m <= (int) 2.487e8)) {
+ (fwrq->m >= 2.412e8) &&
+ (fwrq->m <= 2.487e8)) {
int f = fwrq->m / 10;
int c = 0;
 
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 04/22] media: Move v4l2_fwnode_parse_link from v4l2 to driver base

2019-08-05 Thread Andy Shevchenko
On Tue, Aug 6, 2019 at 2:37 AM Steve Longerbeam  wrote:
>
> There is nothing v4l2-specific about v4l2_fwnode_{parse|put}_link().
> Make these functions more generally available by moving them to driver
> base, with the appropriate name changes to the functions and struct.
>
> In the process embed a 'struct fwnode_endpoint' in 'struct fwnode_link'
> for both sides of the link, and make use of fwnode_graph_parse_endpoint()
> to fully parse both endpoints. Rename members local_node and
> remote_node to more descriptive local_port_parent and
> remote_port_parent.
>

May I ask if it's going to be used outside of v4l2?
Any user in mind?

-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel