From patchwork Mon Nov 12 14:12:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 150839 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3190742ljp; Mon, 12 Nov 2018 06:12:52 -0800 (PST) X-Google-Smtp-Source: AJdET5cD5ICyKtiy5c7iR1chFiXRITTT2CQFB+j/KVA8rGcKkTST3/r16d6Te0nNRs0qn7IaP3th X-Received: by 2002:a62:37c7:: with SMTP id e190-v6mr1033426pfa.145.1542031972259; Mon, 12 Nov 2018 06:12:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542031972; cv=none; d=google.com; s=arc-20160816; b=XJGO11iwJzBg1HuZ2JDzsgp89kEsHkrV/jP3vhSaEr6xwRUP+OC7GiH2ZfOWqtU3nm MvE7NfMTK28EWupk1P2h+/HQfbVMa/N0lrLka/2X8VVID28hlbmotE7BNy56QNC+1PqH ZgzsFnAJM9kYr9fxYYp227XuCEF6n+3yqWNz2gC6hrrXTpWSuMLlhqk+4ncP1TmB/mxU 6oEl9pOqeojrVgHygqHBx5cxjy3hnBPvzQb/9OCoQOmG6k+9mJNBKgh3Ce9lycVgKMiw qs76TFaXdbcoQ0qr50tnYHZMpPnvtF4ENv/NpR4OnKC6k0znmVH7Um89b44baYzq/PoF eDEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=j82EKe+wRAgT6Athn6eo09la18zaAjt/fVKoE3mDKu4=; b=e5H/qsU8sBdv/DQb/NNQY3pDgnyj1TaHakehGP0FyVgsPr139BJhuuM4FdJ2CbdMeL pPl+syDDD00GuNR/c4CG2Mi7HOvskZE7M6kelit/CneYjjVu97/qp+bZ9EnbDSzAW+VN VZeyPG0oK8FnJPhP8P9bKJ5/LJQIOM2OpkxwRbBfOH99jLtGQWw2SUHiw/xoG+somM9q b5dQr25eJMytjBQ3Wj7P9xdWpkHFUj3+meS+fh9hwvF6fojIYA9Y+K0WbwtYBvMnRq57 55plwVtwIqqOKa5xMUpC6fz2/GQPmjtk692RN5U1XZvZwOvt9Oaa8gN5np4rKqkWQw9T beww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iG4r+mLK; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h68-v6si19277640pfb.142.2018.11.12.06.12.52; Mon, 12 Nov 2018 06:12:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=@linaro.org header.s=google header.b=iG4r+mLK; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728505AbeKMAGR (ORCPT + 5 others); Mon, 12 Nov 2018 19:06:17 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41927 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbeKMAGR (ORCPT ); Mon, 12 Nov 2018 19:06:17 -0500 Received: by mail-lj1-f194.google.com with SMTP id z80-v6so7731281ljb.8 for ; Mon, 12 Nov 2018 06:12:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j82EKe+wRAgT6Athn6eo09la18zaAjt/fVKoE3mDKu4=; b=iG4r+mLK5eTJhEUIkhoxf8pviJcETEBujKpfk0OBjA7q/2KEpCKFis2V2aaF7KDwYm b4fBAofgUsLVhnv1ezOvIXhZr4WZ/yLLdlfByJq+p1QS/bTHkDtTIbnRyS1tnmXVq4tI G3OsyRlEicbE5+bWwwld3NcZTQi2OCkoBl6G8= 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=j82EKe+wRAgT6Athn6eo09la18zaAjt/fVKoE3mDKu4=; b=DFkaKOyDS2VBfCJRRQQkB8muVY114rkHaHgiI0PvYAvg3bJG5XLq6to7CFiBoJOLUL aHCvvl2Ot1N3FhkxGu3ubSasnBr7mf0RJ2rX4EkdND08gVS1RHYq1KCxv2jctgBhuOz7 JziT3b1pew2cNRXpd9l5u1tT6vM5mJH/lKgqh4RqUPJvvBR4YfcVB75e4esw7Xt9F+3B qZypuDNiF/H/mjwJ3nOCcShIlGB9LxX3tlvsag/ZNtW1MgPuL5YQZDxlMRV/xI0B/xPz jrJ/Ekn3xN7PEHGITR0BuOYjIFj5Cm8XEcPQW/48/Vqn/OhuN/rKW6V5Ub8264nLdZfi Iedw== X-Gm-Message-State: AGRZ1gKjIuR/o6I7EsxasnP8gYKAT9b01/NRcNtxSqaFfq3r2rX9O0vi SqPm4EJHeMWO9fIRXK2CVGk7UfGKx4JiLw== X-Received: by 2002:a2e:5246:: with SMTP id g67-v6mr777260ljb.73.1542031968565; Mon, 12 Nov 2018 06:12:48 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m14-v6sm3056889lji.29.2018.11.12.06.12.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 06:12:47 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij Subject: [PATCH 01/10] mmc: slot-gpio: Allocate GPIO labels dynamically Date: Mon, 12 Nov 2018 15:12:30 +0100 Message-Id: <20181112141239.19646-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181112141239.19646-1-linus.walleij@linaro.org> References: <20181112141239.19646-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org The use of string pointers in the MMC slot GPIO context is pretty dubious, allocating some 2*len extra bytes for each label of the ro and wp pins. Tidy this up using kasprintf() with dynamic allocation of labels for these strings. Signed-off-by: Linus Walleij --- drivers/mmc/core/slot-gpio.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.17.2 diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 86803a3a04dc..e5bb86b02373 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -27,8 +27,8 @@ struct mmc_gpio { bool override_cd_active_level; irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); char *ro_label; + char *cd_label; u32 cd_debounce_delay_ms; - char cd_label[]; }; static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) @@ -45,15 +45,19 @@ static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) int mmc_gpio_alloc(struct mmc_host *host) { - size_t len = strlen(dev_name(host->parent)) + 4; struct mmc_gpio *ctx = devm_kzalloc(host->parent, - sizeof(*ctx) + 2 * len, GFP_KERNEL); + sizeof(*ctx), GFP_KERNEL); if (ctx) { - ctx->ro_label = ctx->cd_label + len; ctx->cd_debounce_delay_ms = 200; - snprintf(ctx->cd_label, len, "%s cd", dev_name(host->parent)); - snprintf(ctx->ro_label, len, "%s ro", dev_name(host->parent)); + ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL, + "%s cd", dev_name(host->parent)); + if (!ctx->cd_label) + return -ENOMEM; + ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL, + "%s ro", dev_name(host->parent)); + if (!ctx->ro_label) + return -ENOMEM; host->slot.handler_priv = ctx; host->slot.cd_irq = -EINVAL; }