From patchwork Sat Sep 27 01:09:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 38033 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E1BEB202DB for ; Sat, 27 Sep 2014 01:09:53 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf6718622eek.5 for ; Fri, 26 Sep 2014 18:09:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=QMveW+y/A/LQBD8SW+OCoa9VijOCsH+JqAtjoKOZYt8=; b=mWwERCubiEIibcPnp160+Woa0Dfx12mGzgWJMzYP3hUnjG3iVyqDRU/5KzmnxTcBtz ddei9ueyaphxScmP2V3ljKKk+mJpov6dNq826u1b6/1ngRB2aJ7tWa1YA2AMPnf5wNdk aFEC2h0OtIEZjaMug7vyiDR2QZ3sAFhwYCX8xCH8CNcxTW3Xz+nYI8Larme5XUQWV9YB w/C+cDCAIK9zbr07xRu0/nzBDHgo1IcDvyp22ilTx2T9JxFDTvjh+Zyy23BOPngo78Bw wFAUNpCFf9HIiKbRZWrgDj/ZMdQM1ToKG7Xpj9t1fp4S2yVWFqZD1NI9aEfZVHUMbMJf 8nhw== X-Gm-Message-State: ALoCoQnLhZQOar35JOmvgUGEdLKg2T9K/9M3Ey6C/O9z90iaUUlltKROorvGe/VL7+2M6spFx2Vi X-Received: by 10.180.14.225 with SMTP id s1mr1199512wic.5.1411780193024; Fri, 26 Sep 2014 18:09:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.6 with SMTP id j6ls399825lae.24.gmail; Fri, 26 Sep 2014 18:09:52 -0700 (PDT) X-Received: by 10.152.4.165 with SMTP id l5mr24087377lal.49.1411780192829; Fri, 26 Sep 2014 18:09:52 -0700 (PDT) Received: from mail-lb0-x22a.google.com (mail-lb0-x22a.google.com [2a00:1450:4010:c04::22a]) by mx.google.com with ESMTPS id r7si9333295lae.1.2014.09.26.18.09.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Sep 2014 18:09:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22a as permitted sender) client-ip=2a00:1450:4010:c04::22a; Received: by mail-lb0-f170.google.com with SMTP id n15so3676925lbi.1 for ; Fri, 26 Sep 2014 18:09:52 -0700 (PDT) X-Received: by 10.152.8.9 with SMTP id n9mr24122885laa.2.1411780192709; Fri, 26 Sep 2014 18:09:52 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp150954lbb; Fri, 26 Sep 2014 18:09:51 -0700 (PDT) X-Received: by 10.68.68.131 with SMTP id w3mr546497pbt.93.1411780191172; Fri, 26 Sep 2014 18:09:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hf7si7708256pac.63.2014.09.26.18.09.50 for ; Fri, 26 Sep 2014 18:09:51 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751563AbaI0BJn (ORCPT + 27 others); Fri, 26 Sep 2014 21:09:43 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:39888 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750960AbaI0BJk (ORCPT ); Fri, 26 Sep 2014 21:09:40 -0400 Received: by mail-pa0-f45.google.com with SMTP id rd3so4496610pab.4 for ; Fri, 26 Sep 2014 18:09:40 -0700 (PDT) X-Received: by 10.70.130.74 with SMTP id oc10mr35901170pdb.94.1411780180377; Fri, 26 Sep 2014 18:09:40 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id t16sm6029795pdl.32.2014.09.26.18.09.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Sep 2014 18:09:39 -0700 (PDT) From: Behan Webster To: kmo@daterainc.com Cc: behanw@converseincode.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, neilb@suse.de, Arnd Bergmann Subject: [PATCH] md, sysfs, LLVMLinux: Remove nested function from bcache sysfs Date: Fri, 26 Sep 2014 18:09:29 -0700 Message-Id: <1411780169-3260-1-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: behanw@converseincode.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22a as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Replace the use of nested functions where a normal function will suffice. Nested functions are not liked by upstream kernel developers in general. Their use breaks the use of clang as a compiler, and doesn't make the code any better. This code now works for both gcc and clang. Signed-off-by: Behan Webster Suggested-by: Arnd Bergmann Cc: Arnd Bergmann --- drivers/md/bcache/sysfs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index b3ff57d..53d8baa 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -731,6 +731,11 @@ static struct attribute *bch_cache_set_internal_files[] = { }; KTYPE(bch_cache_set_internal); +static int __bch_cache_cmp(const void *l, const void *r) +{ + return *((uint16_t *) r) - *((uint16_t *) l); +} + SHOW(__bch_cache) { struct cache *ca = container_of(kobj, struct cache, kobj); @@ -755,9 +760,6 @@ SHOW(__bch_cache) CACHE_REPLACEMENT(&ca->sb)); if (attr == &sysfs_priority_stats) { - int cmp(const void *l, const void *r) - { return *((uint16_t *) r) - *((uint16_t *) l); } - struct bucket *b; size_t n = ca->sb.nbuckets, i; size_t unused = 0, available = 0, dirty = 0, meta = 0; @@ -786,7 +788,7 @@ SHOW(__bch_cache) p[i] = ca->buckets[i].prio; mutex_unlock(&ca->set->bucket_lock); - sort(p, n, sizeof(uint16_t), cmp, NULL); + sort(p, n, sizeof(uint16_t), __bch_cache_cmp, NULL); while (n && !cached[n - 1])