From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752513AbdGDJ5z (ORCPT ); Tue, 4 Jul 2017 05:57:55 -0400 Received: from mail-qt0-f181.google.com ([209.85.216.181]:35643 "EHLO mail-qt0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752143AbdGDJ5v (ORCPT ); Tue, 4 Jul 2017 05:57:51 -0400 MIME-Version: 1.0 In-Reply-To: References: <1498937290-12285-1-git-send-email-Julia.Lawall@lip6.fr> <20170703133602.ejcdu35ku3i63cj2@earth> <20170703171427.qtpodt7watymphac@earth> <20170703182033.5stv5eq33et63coh@earth> From: Andy Shevchenko Date: Tue, 4 Jul 2017 12:51:15 +0300 Message-ID: Subject: Re: [PATCH] coccinelle: api: detect unnecessary le16_to_cpu To: Julia Lawall Cc: 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" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). -- With Best Regards, Andy Shevchenko