From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbdGDJyH (ORCPT ); Tue, 4 Jul 2017 05:54:07 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:62088 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752040AbdGDJyF (ORCPT ); Tue, 4 Jul 2017 05:54:05 -0400 X-IronPort-AV: E=Sophos;i="5.40,307,1496095200"; d="scan'208";a="281953472" Date: Tue, 4 Jul 2017 11:53:56 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Andy Shevchenko cc: Julia Lawall , Sebastian Reichel , kernel-janitors@vger.kernel.org, Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, "linux-kernel@vger.kernel.org" , Benjamin Tissoires , Bastien Nocera , Stephen Just , "Rafael J . Wysocki" , Len Brown , Robert Moore , Lv Zheng , Mika Westerberg , "linux-acpi@vger.kernel.org" , devel@acpica.org, "linux-pm@vger.kernel.org" Subject: Re: [PATCH] coccinelle: api: detect unnecessary le16_to_cpu In-Reply-To: Message-ID: References: <1498937290-12285-1-git-send-email-Julia.Lawall@lip6.fr> <20170703133602.ejcdu35ku3i63cj2@earth> <20170703171427.qtpodt7watymphac@earth> <20170703182033.5stv5eq33et63coh@earth> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 4 Jul 2017, Andy Shevchenko wrote: > On Tue, Jul 4, 2017 at 12:11 PM, Julia Lawall wrote: > > Here is a revised version (not a patch because it doesn't support all of > > the various modes) and the results. It doesn't return anything beyond > > what was mentioned in previous mails. > > > > For the following code: > > > > ret = i2c_smbus_read_word_data(chip->client, reg << 1); > > val[0] = (u16)ret & 0xFF; > > val[1] = (u16)ret >> 8; > > > > do we want to see: > > > > put_unaligned(val,i2c_smbus_read_word_data(chip->client, reg << 1)); > > If and only if the type of the pointer is a byte type (u8 *, char *, > or alike) _and_ we try to use it as a provider for 16-bit value (2 > bytes). OK, the provider part seems to add more complexity than is worth putting in the rule, so I will let the developer figure out what should be done. thanks, julia