From patchwork Wed Dec 13 11:25:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847948 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="v7MWlk9m"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxZBN1Ztkz9s81 for ; Wed, 13 Dec 2017 22:25:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbdLMLZZ (ORCPT ); Wed, 13 Dec 2017 06:25:25 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:40796 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752415AbdLMLZY (ORCPT ); Wed, 13 Dec 2017 06:25:24 -0500 Received: by mail-wr0-f193.google.com with SMTP id q9so1780706wre.7 for ; Wed, 13 Dec 2017 03:25:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=UD2gqKsYoYi5LSM6a7B5inHWnp+AlbvC7FsVXZ8ztws=; b=v7MWlk9m9Vb93uZbhd9WjR/nqUU7iPW0/T0Nl4Z511wwrMkYvHRZNhiscQ4ZAg0XNR CDQoihvgjSxyEa6JvpIpZ4Z0VX6zZd6DwzXeescN+utyIkWr+cm3fl5LWqdDwxVEnxql PgcO2rySumkHdSQj1UJv5yGe6qAcrc/zzpryZm2tjdy6o+i6wYmRtPY7FrKiCSk0S82g 6b4uyL62xaPSMZrkwjdK5xA4xxzFngH5qW+OJwu6LtAfs+3vB2OVAfvysSoAE8DlHi5r ntqNh+ahnPxHeUVY4vbU3nwmd+plwP3aD1RHTgKVGkjdW3nTYbbv00uFUWAo8dvvrPL+ ziVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UD2gqKsYoYi5LSM6a7B5inHWnp+AlbvC7FsVXZ8ztws=; b=ovFDrJiyf3bGERJ6QJK7Fq3wpH9WD9qSfJhWIRvUc7moJfaCQkaCPgNmznBbtkjkfO jk9uSQJWTgvD/xv+OJk0rDDq4vcSIldGlNALMfSafV3LVkqi4wx+nNhmMBJsh1Iqo+A8 A2NJkNRxlFJieJY7ah2TBYomRYsmJSQbDw51t4VRlw7KYKhgN7vlkK4NmxIeHkxjKXkJ WVOKmIZF7tpxnOVSvZPo16VJoiZQy7qdOy03CDszbW8LRu1qMQGy80/9ZJLBWktqv6Xn Auz7ncWyARqBH5FY1i/GmeNm0I0Z+gxsOnPJOiO9KKlrbxsRCmsN381qcTupet7qUofN LycQ== X-Gm-Message-State: AKGB3mLmeBdSYOpXKOi2xwjMTcwSmtEje8EgFDxGyfkzBA/h8rE9UpAa DH8D+JFiVJpRxKjSELUrXOPRDg== X-Google-Smtp-Source: ACJfBos2q9AnIEJM1oKH3fEn6StUyLv4jFzN50an+WmOW4ZU6oNIB/9NUcZf2It0Ims7KJtOOwnN6Q== X-Received: by 10.223.175.199 with SMTP id y7mr1991511wrd.207.1513164323728; Wed, 13 Dec 2017 03:25:23 -0800 (PST) Received: from bgdev-debian.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id o22sm3484126wrb.40.2017.12.13.03.25.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 03:25:23 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/2] gpiolib: constify label in gpio_device Date: Wed, 13 Dec 2017 12:25:19 +0100 Message-Id: <20171213112520.7479-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.15.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This string is never modified. Make it const. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 5e1f7cc6eeb6..6e9228b94437 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -58,7 +58,7 @@ struct gpio_device { struct gpio_desc *descs; int base; u16 ngpio; - char *label; + const char *label; void *data; struct list_head list; From patchwork Wed Dec 13 11:25:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="WkOfKhGy"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxZBP02Shz9t2M for ; Wed, 13 Dec 2017 22:25:49 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752523AbdLMLZr (ORCPT ); Wed, 13 Dec 2017 06:25:47 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33093 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752676AbdLMLZ0 (ORCPT ); Wed, 13 Dec 2017 06:25:26 -0500 Received: by mail-wm0-f67.google.com with SMTP id g130so21407210wme.0 for ; Wed, 13 Dec 2017 03:25:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ytHg5OZpk+LGLChC69Z1C/7WFDwTbU6ypwmUi8vhWKs=; b=WkOfKhGyFCalSCGyTpe6cm83G2tReegA+wJZNT4CQ24wwdkfXEC+mMvy6DPh2f3zHO mtNuIsmKk130qoAjkxYD+tps2Dq1D/kiQ/O0K8ODMYOS7Eyzc7OMFMg2KUFAw+FKaZEu zJ34CYFFRHrWCgOb7N8njqKTNb9YXJj+uCgoPaawR1gdNVsu7TeX7195sqnItIKG7ry7 lM9v7/freNNnu34q1LrtfMabdo4niohcYOmcawbc2MuNtCbMss+jpDOBPNKdgRKIsiI4 thfMOZ2xdhCZSle5mIyvKoPoHTqKilRQXqkRZlyClAwRx6exs6voTmoizm4YiH5tXuC1 mj4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ytHg5OZpk+LGLChC69Z1C/7WFDwTbU6ypwmUi8vhWKs=; b=XPhBLE76Nc7K/FO84lATJXL1BkI5f9BQSfS+Ju8E4EYF2PDwJQ9uKGExOYyLHoA+ty PRxM7ir/YhSCC7+S5MO4SSy4z5dmgZnzliSu/ej1s6/IfayMFNrclr4dIBKN22F7w1S8 Ie/3rozRsYV8cCtKMLo4ktSt0cmeAFIBDCtpIq15NBk0ic8n+NsLmxIXVpx6UH8XQRaK JW8zJVLwRtDGctQQ9HDDK8nwUIsxYxaXrU3tc0zhYMoVmR35YL1BSIgP8a8xX7Qt59LL +GP6G5QHnEuTtQBhNY/kK5WdAfRzBCbmgCFURGuA+DNafteGdTsNFmMxOaqrWxdLTfJ4 fkHw== X-Gm-Message-State: AKGB3mLOn+mWoLDg6DxDOkoMRsfaeIW0c7sbY9hovDzWq2OKWadbprQ0 ri5kmSgQsyi1HSrwLWcxIhohvQ== X-Google-Smtp-Source: ACJfBotEwFhkm7sjNvBexrFDA3nmzauKpJVTlXh/OXzUCFYj+RdAgz1Nkljvq5fa36laemlz+J7w2A== X-Received: by 10.28.221.138 with SMTP id u132mr1625343wmg.113.1513164324852; Wed, 13 Dec 2017 03:25:24 -0800 (PST) Received: from bgdev-debian.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id o22sm3484126wrb.40.2017.12.13.03.25.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 03:25:24 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/2] gpiolib: use kstrdup_const() for gpio_device label Date: Wed, 13 Dec 2017 12:25:20 +0100 Message-Id: <20171213112520.7479-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171213112520.7479-1-brgl@bgdev.pl> References: <20171213112520.7479-1-brgl@bgdev.pl> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Users often pass a pointer to a static string to gpiochip_add_data() family of functions. Avoid unnecessary memory allocations with the provided helper routine. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 56eec094184c..c078f7f35100 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1062,7 +1062,7 @@ static void gpiodevice_release(struct device *dev) list_del(&gdev->list); ida_simple_remove(&gpio_ida, gdev->id); - kfree(gdev->label); + kfree_const(gdev->label); kfree(gdev->descs); kfree(gdev); } @@ -1171,9 +1171,9 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, } if (chip->label) - gdev->label = kstrdup(chip->label, GFP_KERNEL); + gdev->label = kstrdup_const(chip->label, GFP_KERNEL); else - gdev->label = kstrdup("unknown", GFP_KERNEL); + gdev->label = kstrdup_const("unknown", GFP_KERNEL); if (!gdev->label) { status = -ENOMEM; goto err_free_descs; @@ -1294,7 +1294,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, list_del(&gdev->list); spin_unlock_irqrestore(&gpio_lock, flags); err_free_label: - kfree(gdev->label); + kfree_const(gdev->label); err_free_descs: kfree(gdev->descs); err_free_gdev: