Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warnings, fixes, cleanups #32

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b7a3ea7
Get rid of substituting -p platform with ./platform-debugcc
konradybcio Nov 9, 2023
a0f95bc
meson.build: Borrow CFLAGs from cdba (sans Wpointer-arithmetic)
konradybcio Nov 9, 2023
b954e03
debugcc: Fix format specifier
konradybcio Nov 9, 2023
40888ec
debugcc: Constify measure_clk.name
konradybcio Nov 9, 2023
d79bbff
qcs404: Fix local var shadowing global 'turing'
konradybcio Nov 9, 2023
3c48f5c
sm8650: Use C99 struct initialization
konradybcio Nov 9, 2023
53fe6ea
sm8550: Use C99 struct initialization
konradybcio Nov 9, 2023
bda5320
sm8450: Use C99 struct initialization
konradybcio Nov 9, 2023
9d65df1
sm8350: Use C99 struct initialization
konradybcio Nov 9, 2023
16a9fe2
sm8250: Use C99 struct initialization
konradybcio Nov 9, 2023
bbce445
sm8150: Use C99 struct initialization
konradybcio Nov 9, 2023
e5d39cf
sdm845: Use C99 struct initialization
konradybcio Nov 9, 2023
47f4474
msm8998: Use C99 struct initialization
konradybcio Nov 9, 2023
f982782
msm8996: Use C99 struct initialization
konradybcio Nov 9, 2023
0af3bf8
msm8994: Use C99 struct initialization
konradybcio Nov 9, 2023
6275b39
qcs404: Use C99 struct initialization
konradybcio Nov 9, 2023
33ffb2b
ipq8064: Use C99 struct initialization
konradybcio Nov 9, 2023
11ba03c
msm8936: Use C99 struct initialization
konradybcio Nov 9, 2023
2ec4611
sc8280xp: Use C99 struct initialization
konradybcio Nov 9, 2023
472e3bb
sm6115: Use C99 struct initialization
konradybcio Nov 9, 2023
b70aece
sm6125: Use C99 struct initialization
konradybcio Nov 9, 2023
8e00ed6
sm6350: Use C99 struct initialization
konradybcio Nov 9, 2023
9d01d16
sm6375: Use C99 struct initialization
konradybcio Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 3 additions & 33 deletions debugcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static void measure(const struct measure_clk *clk)
return;
}

printf("%50s: %fMHz (%ldHz)\n", clk->name, clk_rate / 1000000.0, clk_rate);
printf("%50s: %fMHz (%luHz)\n", clk->name, clk_rate / 1000000.0, clk_rate);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit description?

}

static const struct debugcc_platform *find_platform(const char *name)
Expand All @@ -207,32 +207,6 @@ static const struct debugcc_platform *find_platform(const char *name)
return NULL;
}

/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can not say that it is unnecessary. I frequenty run it as platform-debugcc instead of debugcc -p platform.

BTW: is your commit not signed-of, or is it a Github hiding that bit of the commit message?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better would be if debugcc could detect the platform and not have us accidentally map and read/write the wrong memory region for a different platform (resulting in an insta-crash usually).

I tend to do this a lot thanks to shell history.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lumag xkcd 1172 😛

@MarijnS95 should be very doable.. we can probably just read the compatible from /sys/firmware/devicetree

* match_platform() - match platform with executable name
* @argv: argv[0] of the executable
*
* Return: A debugcc_platform when a match is found, otherwise NULL
*
* Matches %s-debugcc against the registered platforms
*/
static const struct debugcc_platform *match_platform(const char *argv)
{
const struct debugcc_platform **p;
const char *name;
size_t len;

for (p = platforms; *p; p++) {
name = (*p)->name;

len = strlen(name);

if (!strncmp(name, argv, len) && !strcmp(argv + len, "-debugcc"))
return *p;
}

return NULL;
}

static const struct measure_clk *find_clock(const struct debugcc_platform *platform,
const char *name)
{
Expand Down Expand Up @@ -309,7 +283,6 @@ static void usage(void)
const struct debugcc_platform **p;

fprintf(stderr, "debugcc <-p platform> [-b blk] <-a | -l | clk>\n");
fprintf(stderr, "<platform>-debugcc [-b blk] <-a | -l | clk>\n");

fprintf(stderr, "available platforms:");
for (p = platforms; *p; p++)
Expand Down Expand Up @@ -350,11 +323,8 @@ int main(int argc, char **argv)
}
}

if (!platform) {
platform = match_platform(argv[0]);
if (!platform)
usage();
}
if (!platform)
usage();

if (do_list_clocks) {
list_clocks_block(platform, block_name);
Expand Down
2 changes: 1 addition & 1 deletion debugcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct gcc_mux {
};

struct measure_clk {
char *name;
const char * const name;
struct debug_mux *clk_mux;
unsigned long mux;

Expand Down
182 changes: 91 additions & 91 deletions ipq8064.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,99 +130,99 @@ static struct debug_mux cpul2_mux = {
};

static struct measure_clk ipq8064_clocks[] = {
{ "sdc1_p_clk", &ls_mux, 0x12 },
{ "sdc1_clk", &ls_mux, 0x13 },
{ "sdc3_p_clk", &ls_mux, 0x16 },
{ "sdc3_clk", &ls_mux, 0x17 },
{ "gp0_clk", &ls_mux, 0x1F },
{ "gp1_clk", &ls_mux, 0x20 },
{ "gp2_clk", &ls_mux, 0x21 },
{ "dfab_clk", &ls_mux, 0x25 },
{ "dfab_a_clk", &ls_mux, 0x25 },
{ "pmem_clk", &ls_mux, 0x26 },
{ "dma_bam_p_clk", &ls_mux, 0x32 },
{ "cfpb_clk", &ls_mux, 0x33 },
{ "cfpb_a_clk", &ls_mux, 0x33 },
{ "gsbi1_p_clk", &ls_mux, 0x3D },
{ "gsbi1_uart_clk", &ls_mux, 0x3E },
{ "gsbi1_qup_clk", &ls_mux, 0x3F },
{ "gsbi2_p_clk", &ls_mux, 0x41 },
{ "gsbi2_uart_clk", &ls_mux, 0x42 },
{ "gsbi2_qup_clk", &ls_mux, 0x44 },
{ "gsbi4_p_clk", &ls_mux, 0x49 },
{ "gsbi4_uart_clk", &ls_mux, 0x4A },
{ "gsbi5_p_clk", &ls_mux, 0x4D },
{ "gsbi5_uart_clk", &ls_mux, 0x4E },
{ "gsbi5_qup_clk", &ls_mux, 0x50 },
{ "gsbi6_p_clk", &ls_mux, 0x51 },
{ "gsbi6_uart_clk", &ls_mux, 0x52 },
{ "gsbi6_qup_clk", &ls_mux, 0x54 },
{ "gsbi7_p_clk", &ls_mux, 0x55 },
{ "gsbi7_uart_clk", &ls_mux, 0x56 },
{ "gsbi7_qup_clk", &ls_mux, 0x58 },
{ "sfab_sata_s_p_clk", &ls_mux, 0x59 },
{ "sata_p_clk", &ls_mux, 0x5A },
{ "sata_rxoob_clk", &ls_mux, 0x5B },
{ "sata_pmalive_clk", &ls_mux, 0x5C },
{ "pcie_src_clk", &ls_mux, 0x5D },
{ "pcie_p_clk", &ls_mux, 0x5E },
{ "ce5_p_clk", &ls_mux, 0x5F },
{ "ce5_core_clk", &ls_mux, 0x60 },
{ "sata_phy_ref_clk", &ls_mux, 0x6B },
{ "sata_phy_cfg_clk", &ls_mux, 0x6C },
{ "sfpb_clk", &ls_mux, 0x78 },
{ "sfpb_a_clk", &ls_mux, 0x78 },
{ "pmic_ssbi2_clk", &ls_mux, 0x7A },
{ "pmic_arb0_p_clk", &ls_mux, 0x7B },
{ "pmic_arb1_p_clk", &ls_mux, 0x7C },
{ "prng_clk", &ls_mux, 0x7D },
{ "rpm_msg_ram_p_clk", &ls_mux, 0x7F },
{ "adm0_p_clk", &ls_mux, 0x80 },
{ "usb_hs1_p_clk", &ls_mux, 0x84 },
{ "usb_hs1_xcvr_clk", &ls_mux, 0x85 },
{ "usb_hsic_p_clk", &ls_mux, 0x86 },
{ "usb_hsic_system_clk", &ls_mux, 0x87 },
{ "usb_hsic_xcvr_fs_clk", &ls_mux, 0x88 },
{ "usb_fs1_p_clk", &ls_mux, 0x89 },
{ "usb_fs1_sys_clk", &ls_mux, 0x8A },
{ "usb_fs1_xcvr_clk", &ls_mux, 0x8B },
{ "tsif_p_clk", &ls_mux, 0x8F },
{ "tsif_ref_clk", &ls_mux, 0x91 },
{ "ce1_p_clk", &ls_mux, 0x92 },
{ "tssc_clk", &ls_mux, 0x94 },
{ "usb_hsic_hsio_cal_clk", &ls_mux, 0x9D },
{ "ce1_core_clk", &ls_mux, 0xA4 },
{ "pcie1_p_clk", &ls_mux, 0xB0 },
{ "pcie1_src_clk", &ls_mux, 0xB1 },
{ "pcie2_p_clk", &ls_mux, 0xB2 },
{ "pcie2_src_clk", &ls_mux, 0xB3 },

{ "afab_clk", &hs_mux, 0x07 },
{ "afab_a_clk", &hs_mux, 0x07 },
{ "sfab_clk", &hs_mux, 0x18 },
{ "sfab_a_clk", &hs_mux, 0x18 },
{ "adm0_clk", &hs_mux, 0x2A },
{ "sata_a_clk", &hs_mux, 0x31 },
{ "pcie_aux_clk", &hs_mux, 0x2B },
{ "pcie_phy_ref_clk", &hs_mux, 0x2D },
{ "pcie_a_clk", &hs_mux, 0x32 },
{ "ebi1_clk", &hs_mux, 0x34 },
{ "ebi1_a_clk", &hs_mux, 0x34 },
{ "usb_hsic_hsic_clk", &hs_mux, 0x50 },
{ "pcie1_aux_clk", &hs_mux, 0x55 },
{ "pcie1_phy_ref_clk", &hs_mux, 0x56 },
{ "pcie2_aux_clk", &hs_mux, 0x57 },
{ "pcie2_phy_ref_clk", &hs_mux, 0x58 },
{ "pcie1_a_clk", &hs_mux, 0x66 },
{ "pcie2_a_clk", &hs_mux, 0x67 },

{ "l2_m_clk", &cpul2_mux, 0x2, 8 },
{ "krait0_m_clk", &cpul2_mux, 0x0, 8 },
{ "krait1_m_clk", &cpul2_mux, 0x1, 8 },
{ .name = "sdc1_p_clk", .clk_mux = &ls_mux, .mux = 0x12 },
{ .name = "sdc1_clk", .clk_mux = &ls_mux, .mux = 0x13 },
{ .name = "sdc3_p_clk", .clk_mux = &ls_mux, .mux = 0x16 },
{ .name = "sdc3_clk", .clk_mux = &ls_mux, .mux = 0x17 },
{ .name = "gp0_clk", .clk_mux = &ls_mux, .mux = 0x1F },
{ .name = "gp1_clk", .clk_mux = &ls_mux, .mux = 0x20 },
{ .name = "gp2_clk", .clk_mux = &ls_mux, .mux = 0x21 },
{ .name = "dfab_clk", .clk_mux = &ls_mux, .mux = 0x25 },
{ .name = "dfab_a_clk", .clk_mux = &ls_mux, .mux = 0x25 },
{ .name = "pmem_clk", .clk_mux = &ls_mux, .mux = 0x26 },
{ .name = "dma_bam_p_clk", .clk_mux = &ls_mux, .mux = 0x32 },
{ .name = "cfpb_clk", .clk_mux = &ls_mux, .mux = 0x33 },
{ .name = "cfpb_a_clk", .clk_mux = &ls_mux, .mux = 0x33 },
{ .name = "gsbi1_p_clk", .clk_mux = &ls_mux, .mux = 0x3D },
{ .name = "gsbi1_uart_clk", .clk_mux = &ls_mux, .mux = 0x3E },
{ .name = "gsbi1_qup_clk", .clk_mux = &ls_mux, .mux = 0x3F },
{ .name = "gsbi2_p_clk", .clk_mux = &ls_mux, .mux = 0x41 },
{ .name = "gsbi2_uart_clk", .clk_mux = &ls_mux, .mux = 0x42 },
{ .name = "gsbi2_qup_clk", .clk_mux = &ls_mux, .mux = 0x44 },
{ .name = "gsbi4_p_clk", .clk_mux = &ls_mux, .mux = 0x49 },
{ .name = "gsbi4_uart_clk", .clk_mux = &ls_mux, .mux = 0x4A },
{ .name = "gsbi5_p_clk", .clk_mux = &ls_mux, .mux = 0x4D },
{ .name = "gsbi5_uart_clk", .clk_mux = &ls_mux, .mux = 0x4E },
{ .name = "gsbi5_qup_clk", .clk_mux = &ls_mux, .mux = 0x50 },
{ .name = "gsbi6_p_clk", .clk_mux = &ls_mux, .mux = 0x51 },
{ .name = "gsbi6_uart_clk", .clk_mux = &ls_mux, .mux = 0x52 },
{ .name = "gsbi6_qup_clk", .clk_mux = &ls_mux, .mux = 0x54 },
{ .name = "gsbi7_p_clk", .clk_mux = &ls_mux, .mux = 0x55 },
{ .name = "gsbi7_uart_clk", .clk_mux = &ls_mux, .mux = 0x56 },
{ .name = "gsbi7_qup_clk", .clk_mux = &ls_mux, .mux = 0x58 },
{ .name = "sfab_sata_s_p_clk", .clk_mux = &ls_mux, .mux = 0x59 },
{ .name = "sata_p_clk", .clk_mux = &ls_mux, .mux = 0x5A },
{ .name = "sata_rxoob_clk", .clk_mux = &ls_mux, .mux = 0x5B },
{ .name = "sata_pmalive_clk", .clk_mux = &ls_mux, .mux = 0x5C },
{ .name = "pcie_src_clk", .clk_mux = &ls_mux, .mux = 0x5D },
{ .name = "pcie_p_clk", .clk_mux = &ls_mux, .mux = 0x5E },
{ .name = "ce5_p_clk", .clk_mux = &ls_mux, .mux = 0x5F },
{ .name = "ce5_core_clk", .clk_mux = &ls_mux, .mux = 0x60 },
{ .name = "sata_phy_ref_clk", .clk_mux = &ls_mux, .mux = 0x6B },
{ .name = "sata_phy_cfg_clk", .clk_mux = &ls_mux, .mux = 0x6C },
{ .name = "sfpb_clk", .clk_mux = &ls_mux, .mux = 0x78 },
{ .name = "sfpb_a_clk", .clk_mux = &ls_mux, .mux = 0x78 },
{ .name = "pmic_ssbi2_clk", .clk_mux = &ls_mux, .mux = 0x7A },
{ .name = "pmic_arb0_p_clk", .clk_mux = &ls_mux, .mux = 0x7B },
{ .name = "pmic_arb1_p_clk", .clk_mux = &ls_mux, .mux = 0x7C },
{ .name = "prng_clk", .clk_mux = &ls_mux, .mux = 0x7D },
{ .name = "rpm_msg_ram_p_clk", .clk_mux = &ls_mux, .mux = 0x7F },
{ .name = "adm0_p_clk", .clk_mux = &ls_mux, .mux = 0x80 },
{ .name = "usb_hs1_p_clk", .clk_mux = &ls_mux, .mux = 0x84 },
{ .name = "usb_hs1_xcvr_clk", .clk_mux = &ls_mux, .mux = 0x85 },
{ .name = "usb_hsic_p_clk", .clk_mux = &ls_mux, .mux = 0x86 },
{ .name = "usb_hsic_system_clk", .clk_mux = &ls_mux, .mux = 0x87 },
{ .name = "usb_hsic_xcvr_fs_clk", .clk_mux = &ls_mux, .mux = 0x88 },
{ .name = "usb_fs1_p_clk", .clk_mux = &ls_mux, .mux = 0x89 },
{ .name = "usb_fs1_sys_clk", .clk_mux = &ls_mux, .mux = 0x8A },
{ .name = "usb_fs1_xcvr_clk", .clk_mux = &ls_mux, .mux = 0x8B },
{ .name = "tsif_p_clk", .clk_mux = &ls_mux, .mux = 0x8F },
{ .name = "tsif_ref_clk", .clk_mux = &ls_mux, .mux = 0x91 },
{ .name = "ce1_p_clk", .clk_mux = &ls_mux, .mux = 0x92 },
{ .name = "tssc_clk", .clk_mux = &ls_mux, .mux = 0x94 },
{ .name = "usb_hsic_hsio_cal_clk", .clk_mux = &ls_mux, .mux = 0x9D },
{ .name = "ce1_core_clk", .clk_mux = &ls_mux, .mux = 0xA4 },
{ .name = "pcie1_p_clk", .clk_mux = &ls_mux, .mux = 0xB0 },
{ .name = "pcie1_src_clk", .clk_mux = &ls_mux, .mux = 0xB1 },
{ .name = "pcie2_p_clk", .clk_mux = &ls_mux, .mux = 0xB2 },
{ .name = "pcie2_src_clk", .clk_mux = &ls_mux, .mux = 0xB3 },

{ .name = "afab_clk", .clk_mux = &hs_mux, .mux = 0x07 },
{ .name = "afab_a_clk", .clk_mux = &hs_mux, .mux = 0x07 },
{ .name = "sfab_clk", .clk_mux = &hs_mux, .mux = 0x18 },
{ .name = "sfab_a_clk", .clk_mux = &hs_mux, .mux = 0x18 },
{ .name = "adm0_clk", .clk_mux = &hs_mux, .mux = 0x2A },
{ .name = "sata_a_clk", .clk_mux = &hs_mux, .mux = 0x31 },
{ .name = "pcie_aux_clk", .clk_mux = &hs_mux, .mux = 0x2B },
{ .name = "pcie_phy_ref_clk", .clk_mux = &hs_mux, .mux = 0x2D },
{ .name = "pcie_a_clk", .clk_mux = &hs_mux, .mux = 0x32 },
{ .name = "ebi1_clk", .clk_mux = &hs_mux, .mux = 0x34 },
{ .name = "ebi1_a_clk", .clk_mux = &hs_mux, .mux = 0x34 },
{ .name = "usb_hsic_hsic_clk", .clk_mux = &hs_mux, .mux = 0x50 },
{ .name = "pcie1_aux_clk", .clk_mux = &hs_mux, .mux = 0x55 },
{ .name = "pcie1_phy_ref_clk", .clk_mux = &hs_mux, .mux = 0x56 },
{ .name = "pcie2_aux_clk", .clk_mux = &hs_mux, .mux = 0x57 },
{ .name = "pcie2_phy_ref_clk", .clk_mux = &hs_mux, .mux = 0x58 },
{ .name = "pcie1_a_clk", .clk_mux = &hs_mux, .mux = 0x66 },
{ .name = "pcie2_a_clk", .clk_mux = &hs_mux, .mux = 0x67 },

{ .name = "l2_m_clk", .clk_mux = &cpul2_mux, .mux = 0x2, 8 },
{ .name = "krait0_m_clk", .clk_mux = &cpul2_mux, .mux = 0x0, 8 },
{ .name = "krait1_m_clk", .clk_mux = &cpul2_mux, .mux = 0x1, 8 },
Comment on lines +219 to +221
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think the last value is missing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works out by total luck but you're right!

{}
};

struct debugcc_platform ipq8064_debugcc = {
"ipq8064",
ipq8064_clocks,
.name = "ipq8064",
.clocks = ipq8064_clocks,
};
31 changes: 31 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,41 @@ project('debugcc',
license: ['BSD-3-Clause'],
meson_version : '>= 0.61.0', # for install_symlink
default_options: [
'warning_level=2', # sets -Wextra
'buildtype=release',
]
)

# Set advanced compiler flags
compiler = meson.get_compiler('c')

compiler_cflags = ['-Wno-unused-parameter',
'-Wno-unused-result',
'-Wno-missing-field-initializers',
'-Wno-sign-compare',
'-Wundef',
'-Wnull-dereference',
'-Wdouble-promotion',
'-Wshadow',
'-Wwrite-strings',
'-Wstrict-overflow=4']

# TODO add clang specific options
if compiler.get_id() == 'gcc'
compiler_cflags += ['-Wformat-signedness',
'-Wduplicated-cond',
'-Wduplicated-branches',
'-Wvla-larger-than=1',
'-Walloc-zero',
'-Wunsafe-loop-optimizations',
'-Wcast-align',
'-Wlogical-op',
'-Wjump-misses-init']
endif

add_global_arguments(compiler.get_supported_arguments(compiler_cflags),
language: 'c')

platforms = [
'ipq8064',
'msm8936',
Expand Down
Loading