From nobody Thu Nov 28 16:38:28 2024 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B282D3D0D5 for ; Mon, 30 Sep 2024 16:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727713937; cv=none; b=saWowxM/Lb+Z+kuS/YTatZbIX2gO6jlGU7BN22jm84HdVree/eYV4OfC21hDJ6VbQLeyaUvtrotTljHB4+Lq6+y+HlTbmyPvFI6mJ92HA0rtOAsTUZgx9c2iZ3zJBxFKLm6r9fOhsADut3aLAmyEV6pG2kssBXReyJW7zTuAovE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727713937; c=relaxed/simple; bh=lCFhn7e2lzr6Ehzz90sWdxjVmd9zawC1JAwvJabCaDI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ppn/QevBk4nxMV3d9Cp5PlsFgVzxVePMHRFcqSjoEccdZzEgJ0kGH6beGzuMSl+6DV5wkLrLFlWt++3SzX7WBkFbqM3YvxAy/G15KyB19GlBHeKr4MqnEf75xzMRwVbdAkkBV7wRkPxjxHMEDa8EUaK+/iL48n0qnx8xTfPyn18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=yKZpSc6n; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="yKZpSc6n" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-37cc5fb1e45so3043301f8f.2 for ; Mon, 30 Sep 2024 09:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1727713933; x=1728318733; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PEr/Oxw9Ncnfg46aBvWmutpmkGHYJGKBOjl+UUCZ+LY=; b=yKZpSc6nrqA0ZB47Sl2gbCNZexZs4Bp6xcvq9o+Qg+uj+Oot7jl8PlIuHNcAiRywOQ hCbXlWQi2jMfD//wQZ9bJdJpUVuq8SouUnM8bWJVDmpxjAbD0eZkKUJGwbIXzMnd2wMf P/avZE0eUJaboUw/YfYQfFn7MmLTwue1bdUm5fF/VxYoEm5xdX127/htolo0TsvRX9IY fd/2XW1isRtbaS4KssbVOc9doKQDOYBk8ZGN76qQIzxGELfgyManUxEVZoT+2+DxAaLG GyCH/TMYVwYW6/BmDURoFL8Ko/x7K1XMXzhQvBmLTh1jl6XnyabCd/put3ypWvK2YY2W lR6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727713933; x=1728318733; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PEr/Oxw9Ncnfg46aBvWmutpmkGHYJGKBOjl+UUCZ+LY=; b=c9OuM+G4aJflpigG8Iiwgp1RzIpN+zK1y9c6Cn9hO7EQJvb2T5o9YlagmVHZc3eCnd RCG3TpWrAcguua6AagSEJgMDzeBJWI8rfgXMi+OOARwnbqY5j1s4GwDoMJsb9hZuxLCG lQog3MbR+EflMwXo8vi+6F5y6kziFYvKV9YhrWw0tTOm3mvqhCXJUqUJVeRZcmzqL+70 d2rWD9+lmx0+7UbC42s8zuytJ3PYaLgeRhw0PQnFU3Qm0fzg3N1LRuJeh/plqDSKa5ny PtKvCgZZPc6JyfJS8Tlbu+w/F+Pr1ry6Na8HvJmwJQq/I85k4NKVyiHVEN2jtdmqCjUa goBA== X-Forwarded-Encrypted: i=1; AJvYcCUTpcZsfOgS4PznsN/4gX53ucjzj6f80xDEcXLZqXZdH3EPbRt+8q+px0DT7ZBplFrI9ytO85hq9y7nwUU=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/liB32VzmnhK+YqGfIF6W//987ug/JCR0kGRGDNjrKBFppVjF f/M+kjCGdNgVovE6pQR7thP1jeHkJQP5wyOOWwpPiG0c55f0Kpj9dqOgD+4YAJA= X-Google-Smtp-Source: AGHT+IGU3mRXJ8Wgr/E9KRt1+fb+zai+1gkk+Suu394wxDlHmgFx+o7pfPkPBJ/DxZ1ZsNEHwcjd+Q== X-Received: by 2002:a05:6000:114a:b0:374:c8e5:d56a with SMTP id ffacd0b85a97d-37cd5b292a5mr7312883f8f.48.1727713932800; Mon, 30 Sep 2024 09:32:12 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:dc:7e00:8791:e3e5:a9ca:31a6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd572fbebsm9405893f8f.72.2024.09.30.09.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 09:32:12 -0700 (PDT) From: Bartosz Golaszewski To: Geert Uytterhoeven , Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH] gpio: aggregator: simplify aggr_parse() with scoped bitmap Date: Mon, 30 Sep 2024 18:32:07 +0200 Message-ID: <20240930163207.80276-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski The bitmap allocated in aggr_parse() is always freed before the function returns so use __free(bitmap) to simplify it and drop the goto label. Signed-off-by: Bartosz Golaszewski Reviewed-by: Geert Uytterhoeven Reviewed-by: Linus Walleij --- drivers/gpio/gpio-aggregator.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c index 38e0fff9afe7..65f41cc3eafc 100644 --- a/drivers/gpio/gpio-aggregator.c +++ b/drivers/gpio/gpio-aggregator.c @@ -65,11 +65,11 @@ static int aggr_parse(struct gpio_aggregator *aggr) { char *args =3D skip_spaces(aggr->args); char *name, *offsets, *p; - unsigned long *bitmap; unsigned int i, n =3D 0; int error =3D 0; =20 - bitmap =3D bitmap_alloc(AGGREGATOR_MAX_GPIOS, GFP_KERNEL); + unsigned long *bitmap __free(bitmap) =3D + bitmap_alloc(AGGREGATOR_MAX_GPIOS, GFP_KERNEL); if (!bitmap) return -ENOMEM; =20 @@ -82,7 +82,7 @@ static int aggr_parse(struct gpio_aggregator *aggr) /* Named GPIO line */ error =3D aggr_add_gpio(aggr, name, U16_MAX, &n); if (error) - goto free_bitmap; + return error; =20 name =3D offsets; continue; @@ -92,13 +92,13 @@ static int aggr_parse(struct gpio_aggregator *aggr) error =3D bitmap_parselist(offsets, bitmap, AGGREGATOR_MAX_GPIOS); if (error) { pr_err("Cannot parse %s: %d\n", offsets, error); - goto free_bitmap; + return error; } =20 for_each_set_bit(i, bitmap, AGGREGATOR_MAX_GPIOS) { error =3D aggr_add_gpio(aggr, name, i, &n); if (error) - goto free_bitmap; + return error; } =20 args =3D next_arg(args, &name, &p); @@ -106,12 +106,10 @@ static int aggr_parse(struct gpio_aggregator *aggr) =20 if (!n) { pr_err("No GPIOs specified\n"); - error =3D -EINVAL; + return -EINVAL; } =20 -free_bitmap: - bitmap_free(bitmap); - return error; + return 0; } =20 static ssize_t new_device_store(struct device_driver *driver, const char *= buf, --=20 2.43.0