Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1112487imm; Tue, 5 Jun 2018 09:15:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLuGN9nKTcJExnFtU5NKGDVt4Mo5dfxL0wn5bVz4G/nvEv3APG/LgJNDrn5rE5Cu5zwJ0L5 X-Received: by 2002:a65:640d:: with SMTP id a13-v6mr21704657pgv.154.1528215319655; Tue, 05 Jun 2018 09:15:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528215319; cv=none; d=google.com; s=arc-20160816; b=TrO6NqnFqF05O0rh3nEtA/BePIkgtT75E46/shzJYjqoSRK0G4b5gz9qpYJzeJV1EL /e47g2BHvWlWGDZmzcbBPU0j4+hUSGyDurK2eeMmNx/Vrm5wXPzZoX9bSZSXTLEpfRaU BqrlkcEvDhMD7KpwzcBjQ+1iC+2yQvyJqHwFTnYxr1zNGBAiKLttK4OmBYeXQssCeQO0 n4rx8w2E+NXKvrPNZpYtFi9rVStISSkrmkC0ZHZFvFukCxKR6fA9OkV/uTYv54S0HRon S+OOBrKrDofxe1V8pE5DAg47wYlazDYAXNrjmgbbK1WBvm2rX4AS+1OWD46MzpeniI51 KzqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=0NYsx0s+BuFmfFEUvjK7mMC6XYyCXxWMpR3OpAOO+14=; b=vWU27O50XgOwatZnZZhEHT5/I7mnjpYy15ATbbAW+ltNefN7e2Dt0AGHs0VLfQgoCp oloF7p+ubAvd5zW5TMATg/w6XBNKYrCjHP6opiRQetfgHTbarrPN+6jkdG4OrrPtnZ+5 uoTZyQFHBJ3uguixraQb4qsTB3zOsvKu7eUvgVvO9ViSI4XyfLjaV9bpOCbBm1I0SWiX R8pl9CUzqGS4Rs8NpLsse1xeTkpjrA89AypyiCYbOO7RRnRO9+KCx+6PX8IYyMWJvK9r 3nnjtObR90CZDLocgtSOL15K/wgwiSReWiDMwO5WbR102D8D+GB3CS7MME/5zA/kxyMQ WmQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HuJwG7y+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6-v6si4501339plp.533.2018.06.05.09.15.05; Tue, 05 Jun 2018 09:15:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HuJwG7y+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751912AbeFEQOh (ORCPT + 99 others); Tue, 5 Jun 2018 12:14:37 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:45833 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751727AbeFEQOf (ORCPT ); Tue, 5 Jun 2018 12:14:35 -0400 Received: by mail-qt0-f193.google.com with SMTP id i18-v6so2985313qtp.12; Tue, 05 Jun 2018 09:14:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=0NYsx0s+BuFmfFEUvjK7mMC6XYyCXxWMpR3OpAOO+14=; b=HuJwG7y+g6Q1XqEG62T7C09nPZkGfiK+EV1hNa5pfSJNrFAWtTQjRy+sTtr/QdXh2V RzqFnHKbMK3Q+pQMnnEJYLg80Xi7yQBoVKrantnK4MyvUtU8fgaE6wDDjFdOrq5qUkjC CFFiRE99IIA4wQ6eQPaQPHsQ9z/XnOUl1sRPB6pAvBr1KQflET9QfrDvn3bFPEXyMH2y 1opgfGdngwAZX1/w6M8U8ujziD6LQnNhSclg1WdXU2cGv6+fhL0CqkVftn//ixcdOUA1 Znrerd/ZrfvaJ17VVg9W6Elsedkfc+tCxLLzuUwCVZedpJengVU9fTWCZOVX0ptynVac w4Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=0NYsx0s+BuFmfFEUvjK7mMC6XYyCXxWMpR3OpAOO+14=; b=m17w0ma+pxcNz76fjQhyghEM4cF/v4RYjIMHd3I3ImVxiXF4d5RxQOTXqnQlxuP4zo Oe9QnTmI1kLWXYVwlR0S/zDaR5MjYvTC0JVzNILw1lbu4dJIeSuPpotPO0QUrdi1xOKO Sil2KLc4YjAfuRtidtEQnb+zqjp+5nIFq2tlKwLlxZa7fC3wfSLrGt3S5V/uUBrgWpA4 cHVdJ64c3vcydMA0crLAPsuihLsD9HuuGwxwxvo2uuIW4E6aBmzou1UJw3VbqILWrZjY U2xuDP4p62qj6MAST0wzuCikHx2LZh/84sODytvXg7gycUFT/JzJM++1ftDL2g8+Oo1P mYdQ== X-Gm-Message-State: APt69E2gpmhfiNUoccNSFn73mDS2sWlFNJBW6Sq/vzzSax8odXWrRcUb VjF8kSWRhFv54AUXTNK4+pE7R2cTlqiaWfAEl8c= X-Received: by 2002:aed:3966:: with SMTP id l93-v6mr9035149qte.220.1528215274847; Tue, 05 Jun 2018 09:14:34 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 09:14:33 -0700 (PDT) In-Reply-To: References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> <1526903890-35761-20-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 5 Jun 2018 19:14:33 +0300 Message-ID: Subject: Re: [PATCH 19/33] thermal: db8500: use match_string() helper To: Yisheng Xie Cc: Linux Kernel Mailing List , Zhang Rui , Eduardo Valentin , Linux PM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 23, 2018 at 10:47 AM, Yisheng Xie wrot= e: > Hi Andy, > > On 2018/5/22 6:00, Andy Shevchenko wrote: >> On Mon, May 21, 2018 at 2:57 PM, Yisheng Xie wr= ote: >>> match_string() returns the index of an array for a matching string, >>> which can be used intead of open coded variant. >> >>> + i =3D match_string((const char **)trip_point->cdev_name, >> >> Casting looks ugly. You need to constify the variable itself. > When I tried to const cdev_name like: > +++ b/include/linux/platform_data/db8500_thermal.h > @@ -27,7 +27,7 @@ > struct db8500_trip_point { > unsigned long temp; > enum thermal_trip_type type; > - char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH]; > + char const cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH]; // co= nst char cdev_name[COOLING_DEV_MAX][THERMAL_NAME_LENGTH] will also the same > }; > > The compiler will also warning: > drivers/thermal/db8500_thermal.c: In function =E2=80=98db8500_thermal_mat= ch_cdev=E2=80=99: > drivers/thermal/db8500_thermal.c:53:2: warning: passing argument 1 of =E2= =80=98match_string=E2=80=99 from incompatible pointer type [enabled by defa= ult] > i =3D match_string(trip_point->cdev_name, COOLING_DEV_MAX, cdev->type); > ^ > In file included from include/linux/bitmap.h:9:0, > from include/linux/cpumask.h:12, > from include/linux/rcupdate.h:44, > from include/linux/radix-tree.h:28, > from include/linux/idr.h:15, > from include/linux/kernfs.h:14, > from include/linux/sysfs.h:16, > from kernel/include/linux/kobject.h:20, > from kernel/include/linux/of.h:17, > from include/linux/cpu_cooling.h:27, > from drivers/thermal/db8500_thermal.c:20: > include/linux/string.h:184:5: note: expected =E2=80=98const char * const*= =E2=80=99 but argument is of type =E2=80=98const char (*)[20]=E2=80=99 > > Any idea? Yes. If you wish to continue, you need to do two patches instead, where in first you are changing fixed array size of pointers to dynamic one and replace or loops from being by size to ones being NULL terminated. --=20 With Best Regards, Andy Shevchenko