Pull CPUFreq Arm updates for 7.3 from Viresh Kumar: "- Minor fixes / cleanups in cpufreq drivers (Dan Carpenter, Guru Das Srinagesh, Haoxiang Li, Karl Mehltretter, Sasha Finkelstein, and Pan Chuang). - Fix cpufreq table creation and bios_limits() callback in the Rust bindings (Priya Bala Govindasamy). - Add IPQ5210 support to qcom-nvmem driver (Varadarajan Narayanan)." * tag 'cpufreq-arm-updates-7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: cpufreq: imx6q: fix out-of-bounds write when probed more than once cpufreq: imx6q: fix devres accumulation across driver rebind rust: cpufreq: Fix temporary write in Registration::bios_limit_callback rust: cpufreq: Add CPUFREQ_TABLE_END as last table entry in TableBuilder::to_table cpufreq: apple-soc: Calculate frequency as a 64-bit value cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate() cpufreq: brcmstb-avs: Remove redundant dev_err() rust: rcpufreq_dt: use vertical import style cpufreq: apple-soc: Fix OPP table cleanup cpufreq: qcom-nvmem: Add IPQ5210 support
Showing the changes to rust/kernel (1 of 8 files). Show all
Unified · Split
| @@ -361,23 +361,28 @@ impl TableBuilder { · 360 unmodified lines | |||
| 361 | } | 361 | } |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | /// Adds a new entry to the table. | 364 | /// Adds a raw frequency-table entry. |
| 365 | pub fn add(&mut self, freq: Hertz, flags: u32, driver_data: u32) -> Result { | 365 | fn push(&mut self, frequency: u32, flags: u32, driver_data: u32) -> Result { |
| 366 | // Adds the new entry at the end of the vector. | 366 | // Adds the new entry at the end of the vector. |
| 367 | Ok(self.entries.push( | 367 | Ok(self.entries.push( |
| 368 | bindings::cpufreq_frequency_table { | 368 | bindings::cpufreq_frequency_table { |
| 369 | flags, | 369 | flags, |
| 370 | driver_data, | 370 | driver_data, |
| 371 | frequency: freq.as_khz() as u32, | 371 | frequency, |
| 372 | }, | 372 | }, |
| 373 | GFP_KERNEL, | 373 | GFP_KERNEL, |
| 374 | )?) | 374 | )?) |
| 375 | } | 375 | } |
| 376 | 376 | ||
| 377 | /// Adds a new entry to the table. | ||
| 378 | pub fn add(&mut self, freq: Hertz, flags: u32, driver_data: u32) -> Result { | ||
| 379 | self.push(freq.as_khz() as u32, flags, driver_data) | ||
| 380 | } | ||
| 381 | |||
| 377 | /// Consumes the [`TableBuilder`] and returns [`TableBox`]. | 382 | /// Consumes the [`TableBuilder`] and returns [`TableBox`]. |
| 378 | pub fn to_table(mut self) -> Result<TableBox> { | 383 | pub fn to_table(mut self) -> Result<TableBox> { |
| 379 | // Add last entry to the table. | 384 | // Add last entry to the table. |
| 380 | self.add(Hertz(c_ulong::MAX), 0, 0)?; | 385 | self.push(bindings::CPUFREQ_TABLE_END as u32, 0, 0)?; |
| 381 | 386 | ||
| 382 | TableBox::new(self.entries) | 387 | TableBox::new(self.entries) |
| 383 | } | 388 | } |
| @@ -823,7 +828,9 @@ pub trait Driver { · 439 unmodified lines | |||
| 823 | } | 828 | } |
| 824 | 829 | ||
| 825 | /// Driver's `bios_limit` callback. | 830 | /// Driver's `bios_limit` callback. |
| 826 | fn bios_limit(_policy: &mut Policy, _limit: &mut u32) -> Result { | 831 | /// |
| 832 | /// Returns HW/BIOS max frequency limitations for the CPU. | ||
| 833 | fn bios_limit(_policy: &mut Policy) -> Result<u32> { | ||
| 827 | build_error!(VTABLE_DEFAULT_ERROR) | 834 | build_error!(VTABLE_DEFAULT_ERROR) |
| 828 | } | 835 | } |
| 829 | 836 | ||
| @@ -1359,9 +1366,12 @@ impl<T: Driver> Registration<T> { · 529 unmodified lines | |||
| 1359 | 1366 | ||
| 1360 | from_result(|| { | 1367 | from_result(|| { |
| 1361 | let mut policy = PolicyCpu::from_cpu(cpu_id)?; | 1368 | let mut policy = PolicyCpu::from_cpu(cpu_id)?; |
| 1362 | 1369 | let val = T::bios_limit(&mut policy)?; | |
| 1363 | // SAFETY: `limit` is guaranteed by the C code to be valid. | 1370 | // SAFETY: `limit` is guaranteed by the C code to be valid. |
| 1364 | T::bios_limit(&mut policy, &mut (unsafe { *limit })).map(|()| 0) | 1371 | unsafe { |
| 1372 | *limit = val; | ||
| 1373 | } | ||
| 1374 | Ok(0) | ||
| 1365 | }) | 1375 | }) |
| 1366 | } | 1376 | } |
| 1367 | 1377 | ||