Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mei: txe: remove unnecessary NULL pointer checks

The .shutdown(), .remove(), and power management callbacks are never called
unless .probe() has already returned success, which means it has set
drvdata to a non-NULL pointer, so "dev" can never be NULL in the other
callbacks.

Remove the unnecessary checks.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20240229181300.352077-3-helgaas@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Bjorn Helgaas and committed by
Greg Kroah-Hartman
64386d15 d6543805

+6 -34
+6 -34
drivers/misc/mei/pci-txe.c
··· 166 166 */ 167 167 static void mei_txe_shutdown(struct pci_dev *pdev) 168 168 { 169 - struct mei_device *dev; 170 - 171 - dev = pci_get_drvdata(pdev); 172 - if (!dev) 173 - return; 169 + struct mei_device *dev = pci_get_drvdata(pdev); 174 170 175 171 dev_dbg(&pdev->dev, "shutdown\n"); 176 172 mei_stop(dev); ··· 187 191 */ 188 192 static void mei_txe_remove(struct pci_dev *pdev) 189 193 { 190 - struct mei_device *dev; 191 - 192 - dev = pci_get_drvdata(pdev); 193 - if (!dev) { 194 - dev_err(&pdev->dev, "mei: dev == NULL\n"); 195 - return; 196 - } 194 + struct mei_device *dev = pci_get_drvdata(pdev); 197 195 198 196 pm_runtime_get_noresume(&pdev->dev); 199 197 ··· 208 218 struct pci_dev *pdev = to_pci_dev(device); 209 219 struct mei_device *dev = pci_get_drvdata(pdev); 210 220 211 - if (!dev) 212 - return -ENODEV; 213 - 214 221 dev_dbg(&pdev->dev, "suspend\n"); 215 222 216 223 mei_stop(dev); ··· 223 236 static int mei_txe_pci_resume(struct device *device) 224 237 { 225 238 struct pci_dev *pdev = to_pci_dev(device); 226 - struct mei_device *dev; 239 + struct mei_device *dev = pci_get_drvdata(pdev); 227 240 int err; 228 - 229 - dev = pci_get_drvdata(pdev); 230 - if (!dev) 231 - return -ENODEV; 232 241 233 242 pci_enable_msi(pdev); 234 243 ··· 256 273 #ifdef CONFIG_PM 257 274 static int mei_txe_pm_runtime_idle(struct device *device) 258 275 { 259 - struct mei_device *dev; 276 + struct mei_device *dev = dev_get_drvdata(device); 260 277 261 278 dev_dbg(device, "rpm: txe: runtime_idle\n"); 262 279 263 - dev = dev_get_drvdata(device); 264 - if (!dev) 265 - return -ENODEV; 266 280 if (mei_write_is_idle(dev)) 267 281 pm_runtime_autosuspend(device); 268 282 ··· 267 287 } 268 288 static int mei_txe_pm_runtime_suspend(struct device *device) 269 289 { 270 - struct mei_device *dev; 290 + struct mei_device *dev = dev_get_drvdata(device); 271 291 int ret; 272 292 273 293 dev_dbg(device, "rpm: txe: runtime suspend\n"); 274 - 275 - dev = dev_get_drvdata(device); 276 - if (!dev) 277 - return -ENODEV; 278 294 279 295 mutex_lock(&dev->device_lock); 280 296 ··· 293 317 294 318 static int mei_txe_pm_runtime_resume(struct device *device) 295 319 { 296 - struct mei_device *dev; 320 + struct mei_device *dev = dev_get_drvdata(device); 297 321 int ret; 298 322 299 323 dev_dbg(device, "rpm: txe: runtime resume\n"); 300 - 301 - dev = dev_get_drvdata(device); 302 - if (!dev) 303 - return -ENODEV; 304 324 305 325 mutex_lock(&dev->device_lock); 306 326