From patchwork Fri Nov 24 21:14:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 169568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1539439vqx; Fri, 24 Nov 2023 13:14:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEobkmkQwmBClh+pznaJHcwP+zNg64+lwIUrHN+aYiXyNT+D8XHAsuN8wwKMnRXAVKQvpvR X-Received: by 2002:a05:6a20:9756:b0:18b:47a9:66e9 with SMTP id hs22-20020a056a20975600b0018b47a966e9mr4116538pzc.40.1700860495531; Fri, 24 Nov 2023 13:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700860495; cv=none; d=google.com; s=arc-20160816; b=ngjkHBll36MUoMxPYWl0JwO+RPksys4YsssoOKERRHKpNzPSRJKrvKCs8fjtLA6vaf 8qfKWUPs2cgIcJHO7o/1BRQ1YqXUJVHJNlRbeusCBXXFmuClTnsTq9rffDceKSvaUJhN uQqV4M9qihTqKq8tf/6UnN9OphVOfxAf434z/EfYRciIFfa2TXxGpAwuTurr5Ef9ahxe Ap9iNZlQ/jS5QrscnuPWO4z3AJjz8VL5yj2w/6H82FSXIcTHVIWa0Fx9htn9TwZzEkwe rOGhOGPohYVdFwzfhwbb2wBs2mimoCLCNxZDIM8rGE+WoSIVpZ1alMiBahxcIsRjeuJB xY2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AjHvTwD5169EQnPtOFzMX5xSY+da/AUya8Bl2YOHLW8=; fh=Plh3gYNf5FIcN97knNQhhQw8YFxg6/B+RkZPcBXowGE=; b=DtFa/OdMh8Mge9RVSgEhZeax41zMNFTNXCr4IOZde4q6RwBKjGxvRM8RxdXyflOQv4 rzI5xZq4fg9cdZy2VT+LDWaPi+KXZPq9TnxnuZhX3n2JQf5d0BPQjBS79/DkVnEx1lh3 cqb5E2kBOOb+hztfi5Jj7wIRK34qrnpDWMZJUbwO3drBr0p4M3kTJQbAeVMxkYSnkmkl KeAu2O39Zt4kGw1D75O2gzpU85nGAmGk0l+4MO0MP1jOYX7qga+6YhEaKe/pUjU8LEVS fgCztqJETC5/OyX13AWwdFK77bVP0t5RXpXH9aCYRyzCpD0OxcHHGCBleEKvkS/wHWin +gKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=oORGNIuz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id k26-20020a63ff1a000000b005be03f0da65si1508663pgi.720.2023.11.24.13.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 13:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=oORGNIuz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 1FB6A8026D93; Fri, 24 Nov 2023 13:14:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbjKXVOl (ORCPT + 99 others); Fri, 24 Nov 2023 16:14:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjKXVOk (ORCPT ); Fri, 24 Nov 2023 16:14:40 -0500 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 438F319A4 for ; Fri, 24 Nov 2023 13:14:46 -0800 (PST) Received: from pop-os.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id 6dVarrd1vODaN6dVarO0tO; Fri, 24 Nov 2023 22:14:43 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1700860483; bh=AjHvTwD5169EQnPtOFzMX5xSY+da/AUya8Bl2YOHLW8=; h=From:To:Cc:Subject:Date; b=oORGNIuzObs23L1jO9Rtgrfd0oMK5aRQcYUmdX5wUHHnFQoaE0uaY/3FBuYJPh3ot u7RaPUl3Y/Q2+mxq4Ml6ZsTq3c4XKR+198COQl/HwM7mzurkhPRC4+8xMVn2wK2nqI Bn+dx7V41/3NGpPi5vMpNvyacQE0F+8z6B7uaVrxfLz95cjDrJ9ddEDJE8rKDdv8hi nCYvo1M7hBvlWtswH7Pm9Fs7EYWxqLM2UPgXsVh6s6ekbuxQz7r5tQ+wAcTBzBFWFP 3tHtHAz906el/xfMeuw7w2OzdMgySt+VUEOzYp1C/mIVXfY8EiAGeisNTykzPjWu09 55hEPTaw7Rjzg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 24 Nov 2023 22:14:43 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: andriy.shevchenko@linux.intel.com, Sudip Mukherjee Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] parport: Save a few bytes of memory Date: Fri, 24 Nov 2023 22:14:36 +0100 Message-Id: <0eba5f2ddd142ab0f577f67e482d1152b40ee720.1700860416.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 24 Nov 2023 13:14:53 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783481494837034898 X-GMAIL-MSGID: 1783481494837034898 Most of parport_register_dev_model() callers pass a 'name' that is a constant string. So kstrdup_const() can be used to save the duplication of this string when it is not needed. This saves a few bytes of memory. Use kfree_const() accordingly when this string is freed. Signed-off-by: Christophe JAILLET Reviewed-by: Andy Shevchenko --- drivers/parport/share.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/parport/share.c b/drivers/parport/share.c index e21831d93305..49c74ded8a53 100644 --- a/drivers/parport/share.c +++ b/drivers/parport/share.c @@ -611,7 +611,7 @@ static void free_pardevice(struct device *dev) { struct pardevice *par_dev = to_pardevice(dev); - kfree(par_dev->name); + kfree_const(par_dev->name); kfree(par_dev); } @@ -682,8 +682,8 @@ parport_register_dev_model(struct parport *port, const char *name, const struct pardev_cb *par_dev_cb, int id) { struct pardevice *par_dev; + const char *devname; int ret; - char *devname; if (port->physport->flags & PARPORT_FLAG_EXCL) { /* An exclusive device is registered. */ @@ -726,7 +726,7 @@ parport_register_dev_model(struct parport *port, const char *name, if (!par_dev->state) goto err_put_par_dev; - devname = kstrdup(name, GFP_KERNEL); + devname = kstrdup_const(name, GFP_KERNEL); if (!devname) goto err_free_par_dev; @@ -804,7 +804,7 @@ parport_register_dev_model(struct parport *port, const char *name, return par_dev; err_free_devname: - kfree(devname); + kfree_const(devname); err_free_par_dev: kfree(par_dev->state); err_put_par_dev: