Files
Linus Torvalds bf4afc53b7 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument
This was done entirely with mindless brute force, using

    git grep -l '\<k[vmz]*alloc_objs*(.*, GFP_KERNEL)' |
        xargs sed -i 's/\(alloc_objs*(.*\), GFP_KERNEL)/\1)/'

to convert the new alloc_obj() users that had a simple GFP_KERNEL
argument to just drop that argument.

Note that due to the extreme simplicity of the scripting, any slightly
more complex cases spread over multiple lines would not be triggered:
they definitely exist, but this covers the vast bulk of the cases, and
the resulting diff is also then easier to check automatically.

For the same reason the 'flex' versions will be done as a separate
conversion.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21 17:09:51 -08:00

57 lines
1.3 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* KUnit fixture to have a (configurable) wiphy
*
* Copyright (C) 2023 Intel Corporation
*/
#include <linux/ieee80211.h>
#include <net/cfg80211.h>
#include <kunit/test.h>
#include <kunit/test-bug.h>
#include "util.h"
int t_wiphy_init(struct kunit_resource *resource, void *ctx)
{
struct kunit *test = kunit_get_current_test();
struct cfg80211_ops *ops;
struct wiphy *wiphy;
struct t_wiphy_priv *priv;
ops = kzalloc_obj(*ops);
KUNIT_ASSERT_NOT_NULL(test, ops);
wiphy = wiphy_new_nm(ops, sizeof(*priv), "kunit");
KUNIT_ASSERT_NOT_NULL(test, wiphy);
priv = wiphy_priv(wiphy);
priv->ctx = ctx;
priv->ops = ops;
/* Initialize channels, feel free to add more here channels/bands */
memcpy(priv->channels_2ghz, channels_2ghz, sizeof(channels_2ghz));
wiphy->bands[NL80211_BAND_2GHZ] = &priv->band_2ghz;
priv->band_2ghz.channels = priv->channels_2ghz;
priv->band_2ghz.n_channels = ARRAY_SIZE(channels_2ghz);
resource->data = wiphy;
resource->name = "wiphy";
return 0;
}
void t_wiphy_exit(struct kunit_resource *resource)
{
struct t_wiphy_priv *priv;
struct cfg80211_ops *ops;
priv = wiphy_priv(resource->data);
ops = priv->ops;
/* Should we ensure anything about the state here?
* e.g. full destruction or no calls to any ops on destruction?
*/
wiphy_free(resource->data);
kfree(ops);
}