devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Tirdea, Irina" <irina.tirdea@intel.com>
Cc: 'Antonio Ospite' <ao2@ao2.it>, Bastien Nocera <hadess@hadess.net>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/9] input: goodix: fix variable length array warning
Date: Fri, 5 Jun 2015 09:40:53 -0700	[thread overview]
Message-ID: <20150605164053.GA26708@dtor-ws> (raw)
In-Reply-To: <1F3AC3675D538145B1661F571FE1805F19A79D7B@irsmsx105.ger.corp.intel.com>

On Fri, Jun 05, 2015 at 04:34:38PM +0000, Tirdea, Irina wrote:
> 
> 
> > -----Original Message-----
> > From: linux-input-owner@vger.kernel.org [mailto:linux-input-owner@vger.kernel.org] On Behalf Of Antonio Ospite
> > Sent: 03 June, 2015 23:50
> > To: Tirdea, Irina
> > Cc: Dmitry Torokhov; Bastien Nocera; linux-input@vger.kernel.org; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: Re: [PATCH 2/9] input: goodix: fix variable length array warning
> > 
> > On Wed, 3 Jun 2015 10:26:47 +0000
> > "Tirdea, Irina" <irina.tirdea@intel.com> wrote:
> > 
> > > > -----Original Message-----
> > > > From: Antonio Ospite [mailto:ao2@ao2.it]
> > > > Sent: 28 May, 2015 18:58
> > > > To: Tirdea, Irina
> > > > Cc: Dmitry Torokhov; Bastien Nocera; linux-input@vger.kernel.org; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> > > > Subject: Re: [PATCH 2/9] input: goodix: fix variable length array warning
> > > >
> > > > On Thu, 28 May 2015 15:47:38 +0300
> > > > Irina Tirdea <irina.tirdea@intel.com> wrote:
> > > >
> > > > > Fix sparse warning:
> > > > > drivers/input/touchscreen/goodix.c:182:26: warning:
> > > > > Variable length array is used.
> > > > >
> > > > > Replace the variable length array with fixed length.
> > > > >
> > > > > Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
> > > > > ---
> > > > >  drivers/input/touchscreen/goodix.c | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> > > > > index c2e785c..dac1b3c 100644
> > > > > --- a/drivers/input/touchscreen/goodix.c
> > > > > +++ b/drivers/input/touchscreen/goodix.c
> > > > > @@ -147,7 +147,7 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
> > > > >   */
> > > > >  static void goodix_process_events(struct goodix_ts_data *ts)
> > > > >  {
> > > > > -	u8  point_data[1 + GOODIX_CONTACT_SIZE * ts->max_touch_num];
> > > > > +	u8  point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
> > > >
> > > > Hi,
> > > >
> > >
> > > Hi Antonio,
> > >
> > > > this fixes the warning from sparse, but also changes the semantics of
> > > > the code: ts->max_touch_num is less that GOODIX_MAX_CONTACTS for 5
> > > > touches devices and in this case we'll end up using more memory than is
> > > > necessary.
> > > >
> > >
> > > I wasn't sure if it is better to save the 5 bytes or fix the warning,
> > > so I sent this to get some more input.
> > > Thanks for the feedback, I will  drop this patch.
> > >
> > 
> > Use kmalloc() or, alternatively, add at least a comment telling why you
> > think that sacrificing a few bytes —only for some devices— has
> > advantages over dynamic allocation.
> > 
> 
> You are right, kmalloc will solve both problems - the sparse warning and allocating
> more bytes than necessary. Don't know why I did not think of that.
> Will use that in v2.

Please leave the patch as is. We can spare 80 bytes on the stack given
that we are running in threaded IRQ. kmallocing will use more code and
runtime resources and won't give any benefits.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-06-05 16:40 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-28 12:47 [PATCH 0/9] Goodix touchscreen enhancements Irina Tirdea
2015-05-28 12:47 ` [PATCH 1/9] input: goodix: fix alignment issues Irina Tirdea
2015-06-04 12:48   ` Bastien Nocera
2015-06-05 16:49   ` Dmitry Torokhov
2015-06-05 17:07     ` Tirdea, Irina
2015-06-05 17:17     ` Joe Perches
2015-06-05 17:31       ` Dmitry Torokhov
2015-05-28 12:47 ` [PATCH 2/9] input: goodix: fix variable length array warning Irina Tirdea
2015-05-28 15:57   ` Antonio Ospite
2015-06-03 10:26     ` Tirdea, Irina
2015-06-03 20:49       ` Antonio Ospite
2015-06-05 16:34         ` Tirdea, Irina
2015-06-05 16:40           ` Dmitry Torokhov [this message]
2015-06-05 17:00             ` Tirdea, Irina
2015-06-05 17:11               ` Dmitry Torokhov
2015-06-05 17:34                 ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 3/9] input: goodix: export id and version read from device Irina Tirdea
2015-05-28 12:47 ` [PATCH 4/9] input: goodix: add ACPI IDs for GT911 and GT9271 Irina Tirdea
2015-06-04 12:51   ` Bastien Nocera
2015-06-05 16:36     ` Tirdea, Irina
2015-06-05 16:41       ` Dmitry Torokhov
2015-06-05 17:01         ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 5/9] input: goodix: reset device at init Irina Tirdea
     [not found]   ` <1432817265-23891-6-git-send-email-irina.tirdea-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-05-28 13:19     ` Mark Rutland
2015-05-28 13:42       ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 6/9] input: goodix: write configuration data to device Irina Tirdea
2015-05-28 13:21   ` Mark Rutland
2015-05-28 13:51     ` Tirdea, Irina
2015-06-04 12:55       ` Bastien Nocera
2015-06-05 16:36         ` Tirdea, Irina
2015-06-05 16:43           ` Dmitry Torokhov
2015-06-05 17:05             ` Tirdea, Irina
2015-05-28 12:47 ` [PATCH 7/9] input: goodix: add power management support Irina Tirdea
2015-06-04 13:01   ` Bastien Nocera
2015-06-05 16:42     ` Tirdea, Irina
     [not found] ` <1432817265-23891-1-git-send-email-irina.tirdea-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-05-28 12:47   ` [PATCH 8/9] input: goodix: add support for ESD Irina Tirdea
     [not found]     ` <1432817265-23891-9-git-send-email-irina.tirdea-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-05-28 13:23       ` Mark Rutland
2015-05-28 14:26         ` Tirdea, Irina
2015-06-04 12:57           ` Bastien Nocera
2015-06-05 16:37             ` Tirdea, Irina
2015-06-05 16:46               ` Dmitry Torokhov
2015-06-08 14:28                 ` Tirdea, Irina
2015-07-30 12:06                   ` Tirdea, Irina
2015-05-28 12:47   ` [PATCH 9/9] input: goodix: use goodix_i2c_write_u8 instead of i2c_master_send Irina Tirdea
2015-06-04 13:04 ` [PATCH 0/9] Goodix touchscreen enhancements Bastien Nocera
2015-06-05 16:36   ` Tirdea, Irina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150605164053.GA26708@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=ao2@ao2.it \
    --cc=devicetree@vger.kernel.org \
    --cc=hadess@hadess.net \
    --cc=irina.tirdea@intel.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).